[Bug 800607] New: system scripts should be scan'ed for bashims, and have 1st line update to bash if used
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=800607 https://bugzilla.novell.com/show_bug.cgi?id=800607#c0 Summary: system scripts should be scan'ed for bashims, and have 1st line update to bash if used Classification: openSUSE Product: openSUSE Factory Version: 12.3 Beta 1 Platform: All OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: suse@tlinx.org QAContact: qa-bugs@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/13.6.28 Many system scripts (400) by one user's count have "bashisms" in them. However, the vast majority of them have #!/bin/sh at the top. Bash claims that it will operate in Posix conformance mode when it is started as /bin/sh, which -- doesn't appear to be happening, but, if fixed, or if the user uses another shell as the POSIX shell replacement (/bin/sh), many scripts may fail unpredictably. Scripts should be scanned at build time for bashism's, and the top line updated to reflect that the script requires/expects to be run with #!/bin/bash if such are included. Reproducible: Always Steps to Reproduce: 1. example - cron-job script for logrotate uses PIPE ARRAY variable. 2. 3. Actual Results: Script usage doesn't match top-line listed interpreter Expected Results: expect that top line would indicate it needs bash if the script includes bashisms. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=800607
https://bugzilla.novell.com/show_bug.cgi?id=800607#c1
Guido Berhörster
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=800607
https://bugzilla.novell.com/show_bug.cgi?id=800607#c2
L. A. Walsh
From comments on the open-suse list:
From: Bernhard Voelker
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=800607
https://bugzilla.novell.com/show_bug.cgi?id=800607#c3
Guido Berhörster
If a script is being run, it is either not working or being ignored.
The rpmlint check (http://gitorious.org/opensuse/rpmlint-checks/blobs/master/BashismsCheck.py) only produces a warning, not an error, so it's possible that package maintainers ignore that (I actually tried to have this enforced more strictly but people objected, look in the opensuse packaging archives around 2010 for the discussion).
I gave an example that doesn't work in a posix compliant shell: one for logrotate.
That looks like a bug, so file a report against logrotate or send a submitrequest.
I found several others on my system that used '[[':
dhcpd dhcpd6 kbd dictd cifs monit named zfs-fuse
I just wasted my time looking at those, dhcpd, dhcpd6, kbd, and zfs-fuse use #!/bin/bash, cifs and named do not use [[ at all, and there is no dictd package in openSUSE.
Just now I tried to run a build of "modules-pam".
The build script uses "pushd" -- a bashism which fails under a posix compliant shell.
Running dash -n doesn't catch bashisms, since [[ and ARRAYS are both illegal syntax -- nor does it catch those bashims where non-existent bash builtins are called (like pushd).
checkbashisms actually does catch [[, pushd/popd, and arrays, however even with the combination of checkbashisms and dash it isn't possible to programatically catch every bashism with 100% certainty at build time.
If you feel this is not an issue, please change /bin/sh -> /bin/dash instead of /bin/bash, as dash also is attempting to be POSIX compliant, just as bash is... You'll find quickly what things don't work. ... like try rebooting your system then.
I'm actually one of the few people who care about this and I wrote the above rpmlint check that scans shellscripts with dash/checkbashisms at buildtime. If you actually find further bashisms then file individual bug reports against the packages. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
![](https://seccdn.libravatar.org/avatar/3035b38ff33cf86f480bb169b8500b80.jpg?s=120&d=mm&r=g)
https://bugzilla.novell.com/show_bug.cgi?id=800607
https://bugzilla.novell.com/show_bug.cgi?id=800607#c4
L. A. Walsh
participants (1)
-
bugzilla_noreply@novell.com