All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nicolas de Pesloüan" <nicolas.2p.debian@gmail.com>
To: Alexander Kurtz <kurtz.alex@googlemail.com>
Cc: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] add proper variable quoting to grub-mkconfig_lib (Debian bug #612417)
Date: Tue, 05 Apr 2011 22:07:46 +0200	[thread overview]
Message-ID: <4D9B7692.2020309@gmail.com> (raw)
In-Reply-To: <1302031960.30533.7.camel@localhost>

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.




  parent reply	other threads:[~2011-04-05 20:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 12:55 [PATCH] add proper variable quoting to grub-mkconfig_lib (Debian bug #612417) Alexander Kurtz
2011-04-05 19:16 ` Nicolas de Pesloüan
2011-04-05 19:30   ` Colin Watson
2011-04-05 19:32   ` Alexander Kurtz
2011-04-05 19:47     ` Colin Watson
2011-04-05 20:07     ` Nicolas de Pesloüan [this message]
2011-04-05 20:53       ` Colin Watson
2011-04-05 21:27         ` Nicolas de Pesloüan
2011-04-06 15:31           ` Alexander Kurtz
2011-04-06 18:14             ` Nicolas de Pesloüan
2011-04-06 19:31               ` Colin Watson
2011-04-06 19:42                 ` Nicolas de Pesloüan
2011-04-08 13:44             ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-04-09 14:32               ` Alexander Kurtz
2011-04-10 13:33                 ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D9B7692.2020309@gmail.com \
    --to=nicolas.2p.debian@gmail.com \
    --cc=grub-devel@gnu.org \
    --cc=kurtz.alex@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.