如何在Bash中禁用shopt选项?

8

如何禁用shopt选项,例如extglob

我在我的.bashrc文件中有这个:

shopt -s extglob

4
有一个选项-u可以禁用它。但问题在于,由于你已经将其放在.bashrc中,该设置会在每个登录 shell 中启用。因此每次想要禁用它时,你需要执行shopt -u extglob - Inian
3
shopt 是 Bash 内置命令。请参阅 help shopt - Cyrus
1个回答

12

使用-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



网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接