What is the intended effective ordering of `set -o` options in bash? Does `histexpand` trump `posix`?

核能气质少年 提交于 2019-12-03 13:31:12

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 and PS2 expansions) will be treated differently with posix 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:

bash-4.2$ set -o | grep 'on$'
braceexpand     on
emacs           on
hashall         on
histexpand      on
history         on
interactive-comments    on
monitor         on
posix           on

None of these are mentioned in the POSIX Shell Command Language documentation (I looked up their shorthands in man bash first), and interactive-comments is not mentioned anywhere.

To turn off history expansion from "!" tokens, use

set +o histexpand

You instead had a "-o" Counter-intuitively, "+o" turns histexpand OFF.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!