Skip to content

Commit

Permalink
Fix pollution with global variables by getopts_long
Browse files Browse the repository at this point in the history
  • Loading branch information
jansorg committed Jul 4, 2024
1 parent d1d256f commit 97e89ac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions bashdb-part2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# I don't know why when this is done in dbg-opts.sh it doesn't have
# an effect.
((OPTLIND > 0)) && shift "$((OPTLIND - 1))"
unset OPTLIND

if (($# == 0)) && [[ -z "$_Dbg_EXECUTION_STRING" ]] ; then
echo >&2 "${_Dbg_pname}: need to give a script to debug or use the -c option."
Expand Down
4 changes: 3 additions & 1 deletion command/backtrace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ function _Dbg_do_backtrace {
_Dbg_not_running && return 3

typeset -i show_source=0
OPTLIND=''
typeset -i OPTLIND=1
typeset OPTLARG OPTLERR OPTLPENDING opt

while getopts_long sh opt \
source no_argument \
help no_argument \
Expand Down
4 changes: 3 additions & 1 deletion command/shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ in the trap EXIT of the shell.
"

_Dbg_parse_shell_cmd_options() {
OPTLIND=''
typeset -i OPTLIND=1
typeset OPTLARG OPTLERR OPTLPENDING opt

while getopts_long lFV opt \
no-fns 0 \
posix no_argument \
Expand Down
1 change: 1 addition & 0 deletions init/opts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ _Dbg_parse_options() {
typeset -i _Dbg_o_quiet=0
typeset -i _Dbg_o_version=0
typeset -i _Dbg_highlight_enabled=1
typeset OPTLARG OPTLERR OPTLPENDING opt

while getopts_long A:Bc:x:hL:nqTt:Yy:VX opt \
annotate required_argument \
Expand Down

0 comments on commit 97e89ac

Please sign in to comment.