Michael Tautschnig
Tue, 03 Oct 2006 12:39:55 -0700
> Hi, > > On Monday 02 October 2006 11:25, you wrote: > > > if [ X$action = Xdirinst ]; then > > > > This is normal shell coding practice. It helps if $action is not defined > > at all. Then the test without quotes "" around an undefined variable > > will give a syntax error. > > Ah :) > > But isn't > > if [ "$action" = "dirinst" ]; then > > > the same and easier to read? > Actually there are reasons to use the X-thing. See, e.g., http://sources.redhat.com/autobook/autobook/autobook_216.html#SEC216 - quoting it here for completeness: "The test command does not cope with missing or additional arguments, so you must take care to ensure that the shell does not remove arguments or introduce new ones during variable and quote expansions. The best way to do that is to enclose any variables in double quotes. You should also add a single character prefix to both sides in case the value of the expansion is a valid option to test:" However, I agree that the above is easier to read and probably expansion to something like "-a" is not an issue here. Cheers, Michael
pgpmf3pciy63C.pgp
Description: PGP signature