如何禁用shopt
选项,例如extglob
?
我在我的.bashrc
文件中有这个:
shopt -s extglob
使用-u
选项:
shopt -u extglob
-s
用于设置,-u
用于取消设置。来自 help shopt
(或在 BSD 系统中也可以使用 shopt --help
):
Options:
-o restrict OPTNAMEs to those defined for use with `set -o'
-p print each shell option with an indication of its status
-q suppress output
-s enable (set) each OPTNAME
-u disable (unset) each OPTNAME
要清晰地了解如何运用shopt,可以参考以下链接:
https://github.com/codeforester/base/blob/master/lib/shopt.sh
-u
可以禁用它。但问题在于,由于你已经将其放在.bashrc
中,该设置会在每个登录 shell 中启用。因此每次想要禁用它时,你需要执行shopt -u extglob
。 - Inianshopt
是 Bash 内置命令。请参阅help shopt
。 - Cyrus