weird xzcat behaviour

Rick Stevens ricks at alldigital.com
Tue Apr 1 18:24:00 UTC 2014


On 04/01/2014 08:47 AM, Mark Haney issued this missive:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> On 04/01/14 11:33, Chris Adams wrote:
>> Once upon a time, Mark Haney <mhaney at practichem.com> said:
>>> sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
>>>
>>> I would get a 'Permission denied' error.
>>
>> That's because the "> /dev/sdb" was parsed and handled by your
>> user shell (redirection is handled by the shell before running the
>> command). sudo only got "xzcat
>> Fedora-Minimal-armhfp-20-1-sda.raw.xz" as arguments.  You should be
>> able to quote what you want actually passed to sudo:
>>
>> sudo "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb"
>>
>
> Well, someone on the Fedora team needs to fix the documentation then.
>   But now it makes sense.  I didn't stop to think about the redirect,
> since my boss isn't giving me time to think.  Apologies for spamming
> the list.

In general, if you're asking a command (in this case sudo) to run
another command (xzcat) and the argument list to that second command
contains spaces, then the entire command should be enclosed by quotes
to keep the shell from processing the arguments and command. Again, this
is standard operation.

This is not Fedora-specific. You'd hit the exact same thing on any Linux
system using the bash shell (I think the other shells would also do
this). Even BSD-derived systems (FreeBSD, Mac OSX) would do this.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital    ricks at alldigital.com -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-            Beware of programmers who carry screwdrivers            -
----------------------------------------------------------------------


More information about the users mailing list