If I turn extglob on to do things likeshopt -s extglobrm !(*.html|*.txt) # remove everything except html and txt filesIs it unwise to keep extglob on after this? Are there any caveats of having it on all the time?
Is it dangerous to always have extglob on?
bash;wildcards
No, it isn't dangerous. The extglob option doesn't increase the risk of accidentally causing damage. The only reason it isn't enabled by default is for backward compatibility with previous versions of bash, and even then, the cases where it breaks compatibility are pretty far-fetched, because most of what extglob enables is a syntax error if it isn't set due to the opening parenthesis occurring in a word.$ bash -c $'echo /@(u|v)*' bash: -c: line 0: syntax error near unexpected token `('bash: -c: line 0: `echo /@(u|v)*'$ bash -c $'shopt -s extglob\necho /@(u|v)*'/usr /varThe only case I can think of where it breaks compatibility with bash -without-extglob and POSIX sh is when a pattern is expanded from a variable. The extglob patterns are unusual in file names, so this is unlikely to be an issue in practice. $ bash -c $'shopt -s extglob\necho $0' '/@(u|v)*'/usr /var$ bash -c $'echo $0' '/@(u|v)*'/@(u|v)*The incompatibilities are sufficiently benign that ksh has these patterns enabled by default, and recent versions of bash can be compiled with the option on by default (./configure --enable-extended-glob-default).