[PATCH] gen_build_files.sh: Remove bashisms
Cristian Ionescu-Idbohrn
cristian.ionescu-idbohrn at axis.com
Tue May 18 11:03:56 UTC 2010
On Mon, 17 May 2010, Paul Smith wrote:
> IMO if you want bash, get bash (and put #!/bin/bash at the top of your
> scripts). If you put #!/bin/sh at the top of your scripts, restrict
> yourself to POSIX shell features.
>
>
> On Mon, 2010-05-17 at 23:54 +0200, Cristian Ionescu-Idbohrn wrote:
> > - local tempname="/tmp/temp.$$.$RANDOM"
> > + local tempname=/tmp/temp.$$
>
> This isn't valid: there's no "local" keyword in POSIX shell.
True.
But all modern shells support it (with some diffrences in
implementation). It helps decluttering the name space, saves a lot of
'unset' commands (which can't be used if you must 'return $variable'
the caller), and makes it easier to avoid unintentionaly overwriting
global variable values.
I don't insist on using it. I guess it's one of those things that
need to be discussed.
> > > wrong. It eats leading and trailing whitespace.
> >
> > I cannot find anything in the opengroup page you earlier referred to:
> >
> > http://www.opengroup.org/onlinepubs/009695399/utilities/read.html
> >
> > saying explicitely "whitespace must me preserved".
>
> Yes, that's what Denys is saying. The rewrite is NOT equivalent to the
> bash version, because the bash version preserves leading/trailing
> whitespace, and the rewrite does not.
And that's what I'm also saying :) Let me rephrase.
Expecting 'read' to preserve leading and trailing whitespace is not
POSIX. It's a bashism. Don't do that. Which makes the rewrite
correct, IMO.
Cheers,
--
Cristian
More information about the busybox
mailing list