Skip to content

Commit

Permalink
shell-integration: be resilient to nounset
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineco authored and wez committed Sep 14, 2024
1 parent 30345b3 commit bcf77a7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions assets/shell-integration/wezterm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# about running programs

# shellcheck disable=SC2166
if [ -z "${BASH_VERSION}" -a -z "${ZSH_NAME}" ] ; then
if [ -z "${BASH_VERSION-}" -a -z "${ZSH_NAME-}" ] ; then
# Only for bash or zsh
return 0
fi

if [ "${WEZTERM_SHELL_SKIP_ALL}" = "1" ] ; then
if [ "${WEZTERM_SHELL_SKIP_ALL-}" = "1" ] ; then
return 0
fi

Expand Down Expand Up @@ -425,7 +425,7 @@ fi;

# blesh provides it's own preexec mechanism which is recommended over bash-preexec
# See https://github.com/akinomyoga/ble.sh/wiki/Manual-%C2%A71-Introduction#user-content-fn-blehook for more details
if [[ ! -n "$BLE_VERSION" ]]; then
if [[ ! -n "${BLE_VERSION-}" ]]; then
__wezterm_install_bash_prexec
fi

Expand All @@ -434,7 +434,7 @@ fi
# It requires the `base64` utility to be available in the path.
__wezterm_set_user_var() {
if hash base64 2>/dev/null ; then
if [[ -z "${TMUX}" ]] ; then
if [[ -z "${TMUX-}" ]] ; then
printf "\033]1337;SetUserVar=%s=%s\007" "$1" `echo -n "$2" | base64`
else
# <https://github.com/tmux/tmux/wiki/FAQ#what-is-the-passthrough-escape-sequence-and-how-do-i-use-it>
Expand Down Expand Up @@ -499,7 +499,7 @@ __wezterm_user_vars_precmd() {
__wezterm_set_user_var "WEZTERM_USER" "$(id -un)"

# Indicate whether this pane is running inside tmux or not
if [[ -n "${TMUX}" ]] ; then
if [[ -n "${TMUX-}" ]] ; then
__wezterm_set_user_var "WEZTERM_IN_TMUX" "1"
else
__wezterm_set_user_var "WEZTERM_IN_TMUX" "0"
Expand All @@ -526,8 +526,8 @@ __wezterm_user_vars_preexec() {
# Register the various functions; take care to perform osc7 after
# the semantic zones as we don't want to perturb the last command
# status before we've had a chance to report it to the terminal
if [[ -z "${WEZTERM_SHELL_SKIP_SEMANTIC_ZONES}" ]]; then
if [[ -n "$BLE_VERSION" ]]; then
if [[ -z "${WEZTERM_SHELL_SKIP_SEMANTIC_ZONES-}" ]]; then
if [[ -n "${BLE_VERSION-}" ]]; then
blehook PRECMD+=__wezterm_semantic_precmd
blehook PREEXEC+=__wezterm_semantic_preexec
else
Expand All @@ -536,8 +536,8 @@ if [[ -z "${WEZTERM_SHELL_SKIP_SEMANTIC_ZONES}" ]]; then
fi
fi

if [[ -z "${WEZTERM_SHELL_SKIP_USER_VARS}" ]]; then
if [[ -n "$BLE_VERSION" ]]; then
if [[ -z "${WEZTERM_SHELL_SKIP_USER_VARS-}" ]]; then
if [[ -n "${BLE_VERSION-}" ]]; then
blehook PRECMD+=__wezterm_user_vars_precmd
blehook PREEXEC+=__wezterm_user_vars_preexec
else
Expand All @@ -546,8 +546,8 @@ if [[ -z "${WEZTERM_SHELL_SKIP_USER_VARS}" ]]; then
fi
fi

if [[ -z "${WEZTERM_SHELL_SKIP_CWD}" ]] ; then
if [[ -n "$BLE_VERSION" ]]; then
if [[ -z "${WEZTERM_SHELL_SKIP_CWD-}" ]] ; then
if [[ -n "${BLE_VERSION-}" ]]; then
blehook PRECMD+=__wezterm_osc7
else
precmd_functions+=(__wezterm_osc7)
Expand Down

0 comments on commit bcf77a7

Please sign in to comment.