[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#29319: Potential tee bug
From: |
Eric Blake |
Subject: |
bug#29319: Potential tee bug |
Date: |
Thu, 16 Nov 2017 10:56:08 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
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
Description: OpenPGP digital signature