How to disable a shopt option in Bash?
Asked Answered
P

1

8

How to disable a shopt option, for example extglob?

I have this in my .bashrc file:

shopt -s extglob
Propriety answered 29/5, 2017 at 5:28 Comment(2)
There is an option -u to disable it. But the problem, is since you have it in .bashrc, the setting is enabled in every login shell. You need to do shopt -u extglob every time you want to disable itKevinkevina
shopt is a bash builtin command. See help shopt.Besant
V
12

Use the -u option:

shopt -u extglob
  • -s is for setting and -u is for unsetting.

From help shopt (or shopt --help as well on BSD systems):

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

To see how to do shopt in a clean way, see this:

https://github.com/codeforester/base/blob/master/lib/shopt.sh

Vitalism answered 29/5, 2017 at 5:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.