Skip to content

Commit 5474fab

Browse files
committed
completion/system: give up hope
Give up and accept defeat that bash-completion can't reasonably be audited for unbound parameters. Wrap invocation with disabling strictness, and restore after if it was enabled.
1 parent de9ea54 commit 5474fab

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

completion/available/system.completion.bash

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
# Loads the system's Bash completion modules.
44
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
55

6+
if shopt -qo nounset
7+
then # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
8+
BASH_IT_RESTORE_NOUNSET=true
9+
shopt -uo nounset
10+
else
11+
BASH_IT_RESTORE_NOUNSET=false
12+
fi
13+
614
if [[ -r "${BASH_COMPLETION:-}" ]] ; then
715
source "${BASH_COMPLETION}"
816
elif [[ -r /etc/bash_completion ]] ; then
@@ -23,3 +31,9 @@ elif [[ $OSTYPE == 'darwin'* ]] && _command_exists brew ; then
2331
source "$BREW_PREFIX"/etc/bash_completion
2432
fi
2533
fi
34+
35+
if $BASH_IT_RESTORE_NOUNSET
36+
then
37+
shopt -so nounset
38+
fi
39+
unset BASH_IT_RESTORE_NOUNSET

0 commit comments

Comments
 (0)