I have a bash script that is run nightly in a cron job. It needs to do case insensitive file matching, so the script callsshopt -s nocaseglobI want to make sure this does not affect other cron scripts. Does this setting persist after this one script ends? Or is this setting enabled only for the duration of the script? Thanks!
Scope of shopt options in cron script
bash;cron;shopt
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.