GNU bug report logs -
#29319
Potential tee bug
Previous Next
Full log
Message #15 received at 29319 <at> debbugs.gnu.org (full text, mbox):
tag 29319 notabug
close 29319
stop
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 environemt
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 "~/Desktop/test.txt";
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 name,
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,
Berny
This bug report was last modified 7 years and 190 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.