Hi,

I got a bug report in debian about bashisms in gnulib
(http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=581105).
Working with a POSIX shell is a release goal for debian squeeze,
along with a switch to dash as /bin/sh.

I had a look with checkbashisms (from the devscripts package in debian
and ubuntu). I've attached the output.

Most instances are either wrapped in tests for their existence, false
positives or otherwise OK, but there are a few I'm not sure about:

* trap with signal numbers

According to http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html
(btw, am I right in saying "The Open Group Base Specifications Issue 6
IEEE Std 1003.1, 2004 Edition" is POSIX, or at least a part of
it?), POSIX requires signals specified as names (HUP, INT, etc),
although XSI allows numbers for certain signals (the ones used by
gnulib all fall into this category).

* type

All uses of 'type' are along the lines of:

> possible bashism in gnulib-tool line 552 (type):
> if (type -p readlink) > /dev/null 2>&1; then

which won't cause a syntax error but could lead to fallback options
being chosen unnecessarily. Could these all be replaced by use of
which(1)?

* shopt

Most uses of shopt are fine, but there is one I'm not sure about:

> possible bashism in tests/init.sh line 112 (shopt):
> test -n "$EXEEXT" && shopt -s expand_aliases

Are there situations where $EXEEXT is set and bash is not running?

thanks,

Ian.

-- 
Ian Beckwith - [email protected] - http://erislabs.net/ianb/
GPG fingerprint: AF6C C0F1 1E74 424B BCD5  4814 40EC C154 A8BA C1EA
possible bashism in tests/test-parse-duration.sh line 33 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in tests/test-fprintf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-file-has-acl.sh line 34 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in tests/test-select-out.sh line 5 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-lseek.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-copy-file.sh line 28 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in tests/test-sigpipe.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-binary-io.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-closein.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/uniwidth/test-uc_width2.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-dprintf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-tsearch.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-c-stack2.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-fpending.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfile' 1 2 3 15
script tests/init.sh does not appear to have a #! interpreter line;
you may get strange results
possible bashism in tests/init.sh line 112 (shopt):
test -n "$EXEEXT" && shopt -s expand_aliases
possible bashism in tests/init.sh line 136 (should be >word 2>&1):
warn_() { echo "$@" 1>&$stderr_fileno_; }
possible bashism in tests/test-c-stack.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-vfprintf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-vdprintf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-yesno.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-vprintf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-select-in.sh line 8 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-idpriv-droptemp.sh line 19 (type):
  if (type sudo) > /dev/null 2>&1; then
possible bashism in tests/test-copy-acl.sh line 34 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in tests/test-set-mode-acl.sh line 34 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in tests/test-perror.sh line 4 (trap with signal numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-idpriv-drop.sh line 19 (type):
  if (type sudo) > /dev/null 2>&1; then
possible bashism in tests/test-printf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-xprintf-posix.sh line 4 (trap with signal 
numbers):
trap 'rm -fr $tmpfiles' 1 2 3 15
possible bashism in tests/test-update-copyright.sh line 27 (trap with signal 
numbers):
trap 'rm -f $TMP_BASE*' 0 1 2 3 15
possible bashism in MODULES.html.sh line 1394 ($RANDOM):
    tmp=$TMPDIR/MD$$-$RANDOM
possible bashism in MODULES.html.sh line 1405 (should be VAR="${VAR}foo"):
if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
possible bashism in lib/t-idcache line 8 (trap with signal numbers):
trap '(exit $?); exit $?' 1 2 13 15
possible bashism in posix-modules line 192 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in posix-modules line 214 (type):
if (type -p readlink) > /dev/null 2>&1; then
possible bashism in build-aux/elisp-comp line 69 (trap with signal numbers):
trap "ret=129; $do_exit" 1
possible bashism in build-aux/elisp-comp line 70 (trap with signal numbers):
trap "ret=130; $do_exit" 2
possible bashism in build-aux/elisp-comp line 71 (trap with signal numbers):
trap "ret=141; $do_exit" 13
possible bashism in build-aux/elisp-comp line 72 (trap with signal numbers):
trap "ret=143; $do_exit" 15
possible bashism in build-aux/install-sh line 204 (trap with signal numbers):
  trap "ret=129; $do_exit" 1
possible bashism in build-aux/install-sh line 205 (trap with signal numbers):
  trap "ret=130; $do_exit" 2
possible bashism in build-aux/install-sh line 206 (trap with signal numbers):
  trap "ret=141; $do_exit" 13
possible bashism in build-aux/install-sh line 207 (trap with signal numbers):
  trap "ret=143; $do_exit" 15
possible bashism in build-aux/install-sh line 345 ($RANDOM):
            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
possible bashism in build-aux/gnu-web-doc-update line 87 (trap with signal 
numbers):
trap 'exit $?' 1 2 13 15
possible bashism in build-aux/csharpcomp.sh.in line 58 ($RANDOM):
    tmp=$TMPDIR/gt$$-$RANDOM
possible bashism in build-aux/csharpcomp.sh.in line 142 (trap with signal 
numbers):
    trap 'rm -rf "$tmp"' 1 2 3 15
possible bashism in gnulib-tool line 101 ($BASH_SOMETHING):
  if test -n "$BASH_VERSION"; then
possible bashism in gnulib-tool line 102 (shopt):
    shopt -s expand_aliases >/dev/null 2>&1
possible bashism in gnulib-tool line 449 ($RANDOM):
    tmp=$TMPDIR/gl$$-$RANDOM
possible bashism in gnulib-tool line 460 (should be VAR="${VAR}foo"):
if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
possible bashism in gnulib-tool line 552 (type):
if (type -p readlink) > /dev/null 2>&1; then
possible bashism in gnulib-tool line 742 (unsafe echo with backslash):
if echo '\t' | grep t > /dev/null; then
possible bashism in gnulib-tool line 757 ($BASH_SOMETHING):
   && test -n "$BASH_VERSION" \
possible bashism in gnulib-tool line 758 (unsafe echo with backslash):
   && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
possible bashism in gnulib-tool line 758 (shopt):
   && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
possible bashism in gnulib-tool line 759 (shopt):
  shopt -o xpg_echo
possible bashism in gnulib-tool line 767 ($BASH_SOMETHING):
     || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
possible bashism in gnulib-tool line 769 ($BASH_SOMETHING):
   && test -n "$BASH_VERSION"; then \
possible bashism in gnulib-tool line 770 (type):
  if type printf 2>/dev/null | grep / > /dev/null; then
possible bashism in gnulib-tool line 785 (unsafe echo with backslash):
  if echo '\t' | grep t > /dev/null; then
possible bashism in gnulib-tool line 797 (type):
   && (type print) >/dev/null 2>&1; then
possible bashism in gnulib-tool line 799 (type):
  if type print 2>/dev/null | grep / > /dev/null; then
possible bashism in gnulib-tool line 810 (unsafe echo with backslash):
   && echo '\t' | grep t > /dev/null; then
possible bashism in gnulib-tool line 831 (unsafe echo with backslash):
   && echo '\t' | grep t > /dev/null; then
possible bashism in gnulib-tool line 854 (unsafe echo with backslash):
if echo '\t' | grep t > /dev/null; then
possible bashism in gnulib-tool line 1538 (declare):
  if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = 
foo; }) 2>/dev/null; then
possible bashism in gnulib-tool line 1549 (declare):
    declare -A modcache_cached
possible bashism in gnulib-tool line 1571 (${parm/?/pat[/str]}):
        cachevar=c_${1//[!a-zA-Z0-9_]/_}
possible bashism in gnulib-tool line 3038 (should be >word 2>&1):
          } >&$ofd
possible bashism in gnulib-tool line 4208 (type):
            if type rsync 2>/dev/null | grep / > /dev/null; then
possible bashism in gnulib-tool line 5434 (alternative test command ([[ foo ]] 
should be [ foo ])):
        s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p

Attachment: signature.asc
Description: Digital signature

Reply via email to