![bash [-+]O shopt_name 没有按照手册预期的方式工作](https://linux22.com/image/15246/bash%20%5B-%2B%5DO%20shopt_name%20%E6%B2%A1%E6%9C%89%E6%8C%89%E7%85%A7%E6%89%8B%E5%86%8C%E9%A2%84%E6%9C%9F%E7%9A%84%E6%96%B9%E5%BC%8F%E5%B7%A5%E4%BD%9C.png)
bash 手册说:
”
[-+]O [shopt_option]
shopt_option is one of the shell options accepted by the
shopt builtin (see SHELL BUILTIN COMMANDS below). If
shopt_option is present, -O sets the value of that option;
+O unsets it. If shopt_option is not supplied, the names
and values of the shell options accepted by shopt are
printed on the standard output. If the invocation option
is +O, the output is displayed in a format that may be
reused as input.
”
但是,假设默认情况下我在当前的 bash 实例上设置了 extglob 选项。现在,如果我通过执行 bash 调用新实例bash +O extglob
,则仍为新实例设置 extglob;它不会为新实例取消设置。但是,如果我现在 shopt -u extglob
在新实例中运行,那么 extglob 将被取消设置。
那么,这是怎么回事?为什么没有bash [-+]O opt_name
效果呢?
我对这个问题唯一的疯狂猜测是,也许当我跑步时bash +O extglob
,它最初引导程序关闭 extglob 的 bash,然后再 bash启动读取所有配置文件,然后启用默认情况下应打开的所有 shopt 选项;就像 extglob 一样。因此,即使最初禁用了 extglob,也要重新启用它。