[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] add proper variable quoting to grub-mkconfig_lib (Debian bug

From: Nicolas de Pesloüan
Subject: Re: [PATCH] add proper variable quoting to grub-mkconfig_lib (Debian bug #612417)
Date: Tue, 05 Apr 2011 22:07:46 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110303 Icedove/3.0.11

Le 05/04/2011 21:32, Alexander Kurtz a écrit :
Am Dienstag, den 05.04.2011, 21:16 +0200 schrieb Nicolas de Pesloüan:
Why do you use construct like "${x}" instead of "$x"?

Because code isn't written once and then stays untouched forever. It
changes over time and may be used in situations you did not anticipate.
Writing solid code (and in shell scripts that definitely includes
quoting your variables) avoids unnecessary bugs like this one.

I've just seen too many poorly written shell scripts with hidden
(sometimes even security-relevant) bugs to not do things properly.

And it looks cleaner ;-)

Best regards

Alexander Kurtz

As Colin says, the {} construct is mostly useless and at least does not 
contribute to quoting.

On the same kind of things, the construct if test "x$foo" = "x" is pointless. It is a very strange heritage from DOS, where IF x%A = x was a common construct, because DOS ( lack quoting. (Is wasn't possible to write IF "%a" = ""). In shell, "" is an empty string, but a real argument to commands. The following construct is the good one : if test "$foo" = "". The test command will receive three arguments: the value of $foo, the = sign and an empty argument and will return true if $foo happens to be empty.

Writing solid code imply - in particular - knowing the exact behaviors of the 
programming language :-)

I agree of course that this is definitely cosmetic, and this doesn't means that your work to remove unquoted variable is not good and necessary.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]