GNU bug report logs - #29319
Potential tee bug

Previous Next

Package: coreutils;

Reported by: Simon Convent <simon.convent <at> rwth-aachen.de>

Date: Thu, 16 Nov 2017 16:45:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29319 in the body.
You can then email your comments to 29319 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#29319; Package coreutils. (Thu, 16 Nov 2017 16:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Simon Convent <simon.convent <at> rwth-aachen.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 16 Nov 2017 16:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Simon Convent <simon.convent <at> rwth-aachen.de>
To: <bug-coreutils <at> gnu.org>
Subject: Potential tee bug
Date: Thu, 16 Nov 2017 17:27:58 +0100
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.


Best regards
Simon




Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Thu, 16 Nov 2017 16:57:01 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Thu, 16 Nov 2017 16:57:02 GMT) Full text and rfc822 format available.

Notification sent to Simon Convent <simon.convent <at> rwth-aachen.de>:
bug acknowledged by developer. (Thu, 16 Nov 2017 16:57:02 GMT) Full text and rfc822 format available.

Message #12 received at 29319-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Simon Convent <simon.convent <at> rwth-aachen.de>, 29319-done <at> debbugs.gnu.org
Subject: Re: bug#29319: Potential tee bug
Date: Thu, 16 Nov 2017 10:56:08 -0600
[Message part 1 (text/plain, inline)]
tag 29319 notabug
thanks

On 11/16/2017 10:27 AM, 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

That's because your use of quoting prevents shell tilde-expansion.  Proof:

$ echo "~/Desktop"
~/Desktop

> 
> But when I run
> 
> echo test | tee "/home/simon/Desktop/test.txt"
> 
> , which is the same directory, tee works fine.

No, that's not the same string.
Proof:

$ echo ~/Desktop
/home/eblake/Desktop

> 
> If I omit the "", everything works fine as well.

That's because without the "", your shell can do tilde-expansion.

> Is this behavior intended? I don't see why the "" should change the
> behavior like this.

dd is not the change in behavior here, but your incorrect understanding
of how shell quoting works.  As such, I'm marking this as not a
coreutils bug (as the argv[] passed to dd is AFTER the shell has already
done tilde-expansion and quote removal, so dd is faithfully trying to
open whatever literal string the shell handed it).  But feel free to
follow up with more questions if you need pointers on learning to use
the shell properly.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#29319; Package coreutils. (Thu, 16 Nov 2017 17:08:01 GMT) Full text and rfc822 format available.

Message #15 received at 29319 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Simon Convent <simon.convent <at> rwth-aachen.de>, 29319 <at> debbugs.gnu.org
Subject: Re: bug#29319: Potential tee bug
Date: Thu, 16 Nov 2017 18:07:44 +0100
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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 15 Dec 2017 12:24:05 GMT) Full text and rfc822 format available.

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.