Maybe I've just triggered an error in bash's parser, but before filing a bugreport I wan't to ask anyways, maybe I'm just getting blind and it's not a bash bug after all ...
This is the script (ok, stripped down version of the actual one):
$ cat bash-parse-error.1.sh
#! /bin/sh
echo "$(
if false
then
exit 0
fi
# echo "("
case FOO in
FOO)
echo "("
;;
esac
)"
$ ./bash-parse-error.1.sh
./bash-parse-error.1.sh: line 12: syntax error near unexpected token `('
./bash-parse-error.1.sh: line 12: ` echo "("'
Now, If I de-comment the extra echo command, the script works as you would expect, printing two opening parenthesises:
$ cat bash-parse-error.2.sh
#! /bin/sh
echo "$(
if false
then
exit 0
fi
echo "("
case FOO in
FOO)
echo "("
;;
esac
)"
$ ./bash-parse-error.2.sh
(
(
Alternatively, removing the if-false-then-exit block (doing whatever I want with the commented out echo command) will make the error go away as well:
$ cat bash-parse-error.3.sh
#! /bin/sh
echo "$(
case FOO in
FOO)
echo "("
;;
esac
)"
$ ./bash-parse-error.3.sh
(
So, is it me or is it bash?
/edit: a) no workaround needed, already got one, thx anyways
b) #! /usr/bash obviously exhibits same problem, because
c) versions tested: 4.3.33(1) and 4.3.39(1)
#! /bin/sh(a space before/bin).sh!=bashwith regard to the tag.#! /bin/shwouldn't be resolved properly.