[Bash-completion-devel] [bug] bash-completion.sh.in: non portable and fragile test

G.raud graud at gmx.com
Sun Mar 16 18:32:03 UTC 2014


Tests with more than 4 arguments are explicitely not supported by POSIX
(unspecified result).

Here is a example that shows that the first test may fail unexpectedly
(although the case is improbable to cause any real problems) using dash
on Debian; the message "sh: 1: [: -a: unexpected operator" is printed
and the rror code 2 is returned:

  BASH_VERSION='=' PS1=x BASH_COMPLETION_COMPAT_DIR= \
    dash -c '[ -n "$BASH_VERSION" -a -n "$PS1" -a -z "$BASH_COMPLETION_COMPAT_DIR" ]'

One should be very cautious when writing profile files that may be
sourced by any (even non Debian-packaged) shells.

Regards



More information about the Bash-completion-devel mailing list