Hello, Clearing out the remainder of my "maybe bugs" file, in no particular order.
1. Arithmetic assignment precedence / associativity. Most shells (and GCC) consider not grouping the assignment in a situation like this an error. Bash tolerates it, apparently reversing associativity: : $((1 == x = 1)) # Error in dash/ksh/mksh/zsh/etc #include <stdio.h> int main() { int n; 5 == n = 5 && printf("%d\n", n); // Error return 0; } 2. += environment assignments 2a. POSIX mode += w/ special builtin. #!/usr/bin/env bash for sh in bash ~/doc/programs/bash43 ksh mksh zsh; do printf '%-7s %s\n' "${sh##*/}:" "$("$sh" /dev/fd/0)" done <<\EOF ${ZSH_VERSION+false}${BASH_VERSION+${POSIXLY_CORRECT=}}||emulate ksh x=2; x+=5 eval printf '"$x "'; echo "$x" # TESTCASE EOF shell | inner | outer bash: 5 2 #(4.2.45) bash43: 5 5 ksh: 25 25 mksh: 25 25 zsh: 25 25 2b. Integer attribute with += environment assignment. The manual doesn't document an exception for += when a command is present. Some shells do arithmetic for += with a command (bash doesn't). #!/usr/bin/env bash for sh in bash ~/doc/programs/bash43 ksh mksh zsh; do printf '%-7s %s\n' "${sh##*/}:" "$("$sh" /dev/fd/0)" done <<\EOF ${ZSH_VERSION+false}${BASH_VERSION+${POSIXLY_CORRECT=}}||emulate ksh typeset -i x=2 x+=5 eval printf '"$x "'; echo "$x" # TESTCASE EOF bash: 5 2 bash43: 5 5 ksh: 7 7 mksh: 25 25 zsh: 7 7 3. RETURN trap doesn't fire upon leaving a function via break or continue. This is a very minor possibly intentional detail. The way break works in this situation is interesting -- maybe useful. function f { case $1 in 3) while :; do f $(($1 - 1)) done ;; 0) trap "printf \$1" RETURN break ;; *) f $(($1 - 1)) esac } # Prints "345" instead of "12345" f 5 4. Invalid compound assignments can become string assignments. If the first character of a regular assignment is an unquoted "(", then if there's a a matching ")", the remainder of the assignment up to the next unquoted metacharacter is assigned as a string. Zsh and ksh honor the ")" of a compound assignment as a metacharacter (to separate commands). mksh and dash treat such an assignment as an error. $ x=()abc; typeset -p x # It might be better to require quoting here. declare -- x="()abc" $ ksh -xc 'x=(foo)typeset -p x' + x=( foo ) + typeset -p x typeset -a x=(foo) 5. Easter egg (test + redirect + $[]) $ trap 'echo "$BASH_COMMAND"; trap - DEBUG' DEBUG $ [ <& $[ ] [ = [ && printf '%s\n' "$_ ...ha :)" [ [ = [ 0<&$[ ] [ ...ha :) I like this. :) 6. Indirection combined with another modifier expands arrays to a single word. $ a=({a..c}) b=a[@]; printf '<%s> ' "${!b}"; echo; printf '<%s> ' "${!b/%/foo}"; echo <a> <b> <c> <a b cfoo> I might have already reported this but can't find it. Ignore if so. -- Dan Douglas