Subject: Re: CVS commit: basesrc
To: None <nisimura@netbsd.org>
From: Dave Sainty <dave@dtsp.co.nz>
List: source-changes
Date: 11/26/2000 18:31:48
Tohru Nishimura writes:

> Module Name:	basesrc
> Committed By:	nisimura
> Date:		Tue Nov 21 08:39:51 UTC 2000
> 
> Modified Files:
> 	basesrc/etc/rc.d: network
> 
> Log Message:
> Shell programming police for sophistication.  It's not necessary
> to enclose `prog` backquote command substitution with double quotes
> as it produces a quoted string.  Other changes are pending this time.

This isn't correct.  Proof by counter-example (the quotes matter):

$ [ -z `echo x -o -n x` ] && echo yes || echo no
yes
$ [ -z "`echo x -o -n x`" ] && echo yes || echo no
no
$ [ -z `echo x -o -z x` ] && echo yes || echo no
no
$ [ -z "`echo x -o -z x`" ] && echo yes || echo no
no

So, for example, this part of this change is incorrect (at least from
a "quote-correctness" point of view):

-               if ! checkyesno dhclient && [ -z "`hostname`" ]; then
+               if ! checkyesno dhclient && [ -z `hostname` ]; then

(The old version was correct, the new version makes assumptions about
the contects of the output of "hostname", that it doesn't contain
whitespace.  A pretty safe assumption, but...)

Cheers,

Dave