[PATCH] gen_build_files.sh: Remove bashisms

Paul Smith paul at mad-scientist.net
Tue May 18 00:18:28 UTC 2010


Definitely put me down in the camp that does NOT want to add a lot of
bash-specific features to the default shell.

The default shell should be POSIX, nothing more.  Anything else runs the
risk of introducing incompatibilities with standard POSIX scripts,
resulting in failures!

For example, what if I write a shell script that defines a shell
function "source"; now that we support the bash "source" builtin that
script, which works fine with any POSIX shell AND with (older, anyway)
versions of dash, will fail.  Etc.

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.


> > 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.  Not sure that matters in this
case, but it's true nonetheless:

        ~$ cat > /tmp/booar
           this    is     a     file    
        
        ~$ read -r foo < /tmp/booar
        ~$ echo "|$foo|"
        |this    is     a     file|
        
        ~$ read -r < /tmp/booar
        ~$ echo "|$REPLY|"
        |   this    is     a     file    |





More information about the busybox mailing list