[Pkg-sysvinit-devel] Bug#653077: initscripts: cleanup patches for /etc/network/if-up.d/mountnfs
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Sat Dec 24 13:54:25 UTC 2011
On Sat, 24 Dec 2011, Petter Reinholdtsen wrote:
> [Cristian Ionescu-Idbohrn]
> > Please find attached a series of 21 patches, attempt to cleanup,
> > robustify and improve performance and maintability of that script
> > (triggerd by bug#625726.
>
> I noticed you removed quite a lot of quotes around variables, which in
> my view is to make the code less robust. Why do you propose to remove
> quotes around constructs like this:
>
> > - case "$FSTYPE" in
> > + case $FSTYPE in
>
> I try to always put quotes around such variables as far of an effort to
> do defensive programming, in case a space sneak into its value some time
> in the future.
Because 'case' is special and does not require quotes.
Everything between 'case' and 'in' is tested (even the empty string).
Consider this example (put your prefered shell on the shebang line):
---8<---
#!/bin/sh
set -eu
#set -x
foo="the quick brown fox jumps over the lazy dog"
bar=
case $foo in
*fox*)
echo "matched '$foo'"
;;
*)
echo missed foo
;;
esac
case $bar in
'')
echo "matched empty '$bar'"
;;
*)
echo missed bar
;;
esac
--->8---
Cheers,
--
Cristian
More information about the Pkg-sysvinit-devel
mailing list