fai-cd: quotes around command for -x test

Michael Tautschnig mt at debian.org
Wed Oct 13 23:23:00 CEST 2010


Hi again,

> Hello,
> 
> There should be quotes around the $(command) for the -x test shell
> builtin: [ -x "$(command)" ]
> This is owing to the following:
> 
> debian:~# which rsync
> /usr/bin/rsync
> debian:~# which rsync_x
> debian:~# [ -x "$(which rsync)" ] && echo ok
> ok
> debian:~# [ -x "$(which rsync_x)" ] && echo ok
> debian:~# [ -x $(which rsync) ] && echo ok
> ok
> debian:~# [ -x $(which rsync_x) ] && echo ok
> ok
> debian:~#
> 

[...]

Thanks a lot for debugging this; in fact I wonder whether you do some kind of
(automated?) code inspection or what is it that makes you discover all these
hidden issues!?

Furthermore, thanks for providing the nice counter-example. I must, however,
admit that I don't quite like the patch. Or, rather, I'd like to go a bit
further. The quotes are fine and maybe even necessary to catch cases where the
path to rsync contains whitespace. This, however, will likely cause a number of
other errors and won't be seen on too many systems. To catch the more likely
case of a missing rsync command I'd suggest the following:

which rsync && [ -x $(which rsync) ] && echo ok

(Well, maybe even a which rsync && echo ok would be just as fine.)

Comments are welcome!

Best,
Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
Url : http://lists.uni-koeln.de/pipermail/linux-fai-devel/attachments/20101013/5ad9ab2b/attachment.bin 


More information about the linux-fai-devel mailing list