On Thu, Jan 24, 2013 at 12:42:51AM -0800, Linda Walsh wrote:
I'm constantly seeing system scripts starting with #!/bin/sh which tells BASH to run in POSIX conformance mode, yet occasionally, more or less randomly, I'll see "BASHism's" in the script.
Case in point: the cron job for logrotate references the Array PIPESTATUS to get at the exit value of log rotate.
True.
Arrays and PIPESTATUS never used to be part of POSIX.
True.
Also a quick grep turns up startup scripts, using Bash's '[[' syntax, such as:
AFAIK the `[[ ... ]]' is known in latest POSIX, see e.g. http://manuals.ts.fujitsu.com/file/8867/posix_k.pdf on page 44 and page 57ff. And not only the bash does it use but also the ksh, IMHO most user should use this for any Conditional Expression instead of the `test ...' or the '[ ... ]' builtin to be sure not run into trouble if regular experssions are used ;) Also the `let ...' builtin ... or its equivalent `(( ... ))' for integer arithmetic's are well known, see page 448ff.
boot.localfs boot.kdump dhcpd dhcpd6 kbd dictd cifs monit mysql named zfs-fuse
Shouldn't these scripts be invoked as #!/bin/bash?
Maybe some of them run because they are invoked as bash -c <script>, but it seems problematic to state that it is to be used with #!/bin/sh at the top of a script but be using "Bashism's" in the script.
On my own system, I change the line at the top to say #!/bin/bash if the script uses Bash syntax. Maybe that should become the standard prefix if system scripts are going to be using Bash syntax?
Werner -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org