I attempted to answer a question a couple hours ago which I believed revealed a somewhat obscure bug in bash POSIX mode. I was hastily and vehemently told this was not so. The contradicting answer, which explicitly says this is not a bug, was selected as the correct answer.
So I've been combing over the bash documentation, and I'm still coming away with very much the same impression, so I thought I should ask.
My (alleged) bug:
set -o histexpand
(which is typically implicit)
set -o posix
echo "#!/"
Should, well, echo #!/
. (It does in any other shell). But in bash it instead
prints to standard output
!/: event not found
And then returns 0.
So it would seem to me that bash's implicit set -o histexpand
is in rare cases in contravention of the POSIX standard, and does not make way for set -o posix
.
The documentation for set -o posix
reads:
Change the behavior of Bash where the default operation differs from the POSIX standard ... This is intended to make Bash behave as a strict superset of that standard.
And I've always thought that this meant that this option should supersede other set
options when they contradict?
This doesn't appear to be one of the 48 enumerated differences either.
Is this not the case? What am I missing?
From the Bash POSIX Mode reference I would expect the behaviour you're seeing - it doesn't say anywhere on that list that history numbers (outside of
PS1
andPS2
expansions) will be treated differently withposix
set. Also, since others said it was not a bug I guess the meaning of "superset" is that as long as no Bash-specific settings are in place the shell will behave according to the POSIX standard.Interestingly, even if you run
bash --noprofile --norc --posix
some Bash-specific settings are on by default:None of these are mentioned in the POSIX Shell Command Language documentation (I looked up their shorthands in
man bash
first), andinteractive-comments
is not mentioned anywhere.To turn off history expansion from "!" tokens, use
You instead had a "-o" Counter-intuitively, "+o" turns histexpand OFF.