Browse Source

fix(termsupport): ensure ohmyzsh can run with `set -eu`

Closes #12870
Carlo Sala 1 month ago
parent
commit
5eaebdf0fe
2 changed files with 4 additions and 2 deletions
  1. 2 1
      lib/async_prompt.zsh
  2. 2 1
      lib/termsupport.zsh

+ 2 - 1
lib/async_prompt.zsh

@@ -26,7 +26,7 @@ autoload -Uz is-at-least
 # This API is subject to change and optimization. Rely on it at your own risk.
 # This API is subject to change and optimization. Rely on it at your own risk.
 
 
 function _omz_register_handler {
 function _omz_register_handler {
-  setopt localoptions noksharrays
+  setopt localoptions noksharrays unset
   typeset -ga _omz_async_functions
   typeset -ga _omz_async_functions
   # we want to do nothing if there's no $1 function or we already set it up
   # we want to do nothing if there's no $1 function or we already set it up
   if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
   if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
@@ -44,6 +44,7 @@ function _omz_register_handler {
 
 
 # Set up async handlers and callbacks
 # Set up async handlers and callbacks
 function _omz_async_request {
 function _omz_async_request {
+  setopt localoptions noksharrays unset
   local -i ret=$?
   local -i ret=$?
   typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
   typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
 
 

+ 2 - 1
lib/termsupport.zsh

@@ -47,7 +47,7 @@ fi
 
 
 # Runs before showing the prompt
 # Runs before showing the prompt
 function omz_termsupport_precmd {
 function omz_termsupport_precmd {
-  [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
+  [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
   title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
   title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
 }
 }
 
 
@@ -145,6 +145,7 @@ esac
 # Identifies the directory using a file: URI scheme, including
 # Identifies the directory using a file: URI scheme, including
 # the host name to disambiguate local vs. remote paths.
 # the host name to disambiguate local vs. remote paths.
 function omz_termsupport_cwd {
 function omz_termsupport_cwd {
+  setopt localoptions unset
   # Percent-encode the host and path names.
   # Percent-encode the host and path names.
   local URL_HOST URL_PATH
   local URL_HOST URL_PATH
   URL_HOST="$(omz_urlencode -P $HOST)" || return 1
   URL_HOST="$(omz_urlencode -P $HOST)" || return 1