Setting options with shopt
is a shell setting. It only affects the shell instance that you run it in: it is local to the shell process and to subshells invoked by $(…)
, (…)
and similar constructs. It has no effect on other shell scripts executed concurrently or later, nor even on independent bash scripts that happen to be executed from commands executed by this script.
The same applies to the values and types of variables, as long as they aren't exported. It's also possible to have variables that are local to a function; options are always global, in the sense that if you set them in a function, they remain in place when the function returns.
Environment variables (i.e. exported variables), I/O redirections, resource limits, umask, current directory and a number of other settings apply to the current shell process as well as to all subprocesses (i.e. all commands invoked by that script). They too do not escape to unrelated processes that may be executed concurrently.
shopt
option likeglobstar
persistently, would the best way to do that be simply addingshopt -s globstar
to my.bash_profile
? – Taylor D. Edmiston Feb 14 '19 at 16:48.bash_profile
only takes effect in login shells. If you want it to apply to all interactive shells, put this in.bashrc
. See https://unix.stackexchange.com/questions/122187/is-there-a-bash-file-that-will-be-always-sourced-in-interactive-mode-no-matter-i/122188#122188 If you want it to apply in a script, it needs to be in the script itself. – Gilles 'SO- stop being evil' Feb 14 '19 at 17:47