Handle unset variables in various parts of the codebase (#8944)
DISABLE_UNTRACKED_FILES_DIRTY, DISABLE_AUTO_TITLE, GIT_STATUS_IGNORE_SUBMODULES are not set
Handle these variables not being set with conditional access.
If the user has set -u option to report attempts to use undeclared / unassigned variable, accessing the variables needs to be conditional.
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index 00cb00b19e81de958c54d6a548be146ac9a7563a..f7d4738caf2126d96f0e278901c6f863cb031303 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -14,10 +14,10 @@ function parse_git_dirty() {
6 local -a FLAGS
7 FLAGS=('--porcelain')
8 if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
9- if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
10+ if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
11 FLAGS+='--untracked-files=no'
12 fi
13- case "$GIT_STATUS_IGNORE_SUBMODULES" in
14+ case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
15 git)
16 # let git decide (this respects per-repo config in .gitmodules)
17 ;;
18diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
19index e3237ca3449d814d12473ee361eb93f7f5194e4d..069b7f3288b259596e0d702486548f522f40a587 100644
20--- a/lib/termsupport.zsh
21+++ b/lib/termsupport.zsh
22@@ -50,13 +50,13 @@ fi
2324 # Runs before showing the prompt
25 function omz_termsupport_precmd {
26- [[ "$DISABLE_AUTO_TITLE" == true ]] && return
27+ [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
28 title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
29 }
3031 # Runs before executing the command
32 function omz_termsupport_preexec {
33- [[ "$DISABLE_AUTO_TITLE" == true ]] && return
34+ [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
3536 emulate -L zsh
37 setopt extended_glob