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 (command.com) 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.

        Nicolas.



_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to