> However, who is it that is too hungry for the next ")"?: > $ k=$(case x in x) :;; esac) > bash: syntax error near unexpected token `;;' > $ k=$(case x in x) :; esac) > bash: syntax error near unexpected token `esac' > $ k=`case x in x) :; esac`
I believe this is a bug in bash 3.0. I have confirmed that it still exists in bash-3.1-beta1, but have not yet tested if bash 3.1 final patchlevel 1 has fixed the bug. POSIX requires (http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_03) that in the $(command) form, "Any valid shell script can be used for command." The rationale page (http://www.opengroup.org/onlinepubs/009695399/xrat/xcu_chap02.html) then proceeds to list several examples of $() commands where an unmatched ')' can appear inside the nested command, when used as part of a valid shell script (although it did not list the example of case with unmatched ')'). Furthermore, the rationale page states under the Case Conditional Construct: "At one time, using the leading parenthesis was required if the case statement was to be embedded within a "$()" command substitution; this is no longer the case with the POSIX shell." Therefore, I read this as stating that POSIX requires your example to succeed, and that bash has a bug (FYI, the bug also appears in my installed versions of zsh and ksh). Meanwhile, as a workaround, use: $ k=$(case x in (x) :; esac) -- Eric Blake _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash