If consecutive case statements are inside of $(...), the parser
misinterprets first ')' from second case statement as the end of command
substitution.
The possibly related patch bash43-042 is already included in this version.
Repeat-By:
$ cat bug.sh
x=$(
case 1 in
1) echo 1
esac
case 2 in
2) echo 2
esac
)
echo "$x"
$ bash -xv bug.sh
x=$(
case 1 in
1) echo 1
esac
case 2 in
2) echo 2
bug.sh: command substitution: line 13: syntax error: unexpected end of file
bug.sh: line 7: syntax error near unexpected token `esac'
bug.sh: line 7: ` esac'
$ dash bug.sh
1
2
Workarounds:
- append semicolon behind first 'esac', or
- insert any command line between the case statements, or
- use `...` instead of $(...)
--
Christian Franke