[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29319: Potential tee bug

From: Bernhard Voelker
Subject: bug#29319: Potential tee bug
Date: Thu, 16 Nov 2017 18:07:44 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

tag 29319 notabug
close 29319

On 11/16/2017 05:27 PM, Simon Convent wrote:
> Hello,
> when I run the command
> echo test | tee "~/Desktop/test.txt"
> I get the following error message:
> tee: ~/Desktop/test.txt: No such file or directory
> But when I run
> echo test | tee "/home/simon/Desktop/test.txt"
> , which is the same directory, tee works fine.
> If I omit the "", everything works fine as well.
> Is this behavior intended? I don't see why the "" should change the behavior 
> like this.

Without quotes, the shell expands the ~ symbol to the value of the HOME 
variable, "/home/simon" in your case, and passes that to tee as argument:

  $ echo tee "~/Desktop/test.txt"
  tee ~/Desktop/test.txt

  $ echo test | echo tee ~/Desktop/test.txt
  tee /home/voelkerb/Desktop/test.txt

Therefore, tee tries to open the file with the (relative) file name 
and as you most probably do not have a directory hierarchy '~' and '~/Desktop' 
in your
working directory, tee fails.

If you want the tilde expantion and have to quote some other part of the file 
then you can do so:

  $ echo text | tee ~/"My Documents/test.txt"

Thus, this is not a bug in tee, but in your expectations regarding the shell's 
tilde expansion
(man bash, then search for "Tilde expansion").  I'n hereby marking and closing 
this issue
as such in our bug tracker.

Have a nice day,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]