From 5c1cf2feea6e9e0cee5932a8460283620361d7bd Mon Sep 17 00:00:00 2001 From: Steven Shaw Date: Mon, 11 May 2015 07:27:21 +0000 Subject: [PATCH] Make friendly to `set -u` --- lib/completion.zsh | 2 +- lib/correction.zsh | 2 +- lib/git.zsh | 2 +- lib/history.zsh | 4 ++-- lib/misc.zsh | 2 +- lib/termsupport.zsh | 10 +++++----- lib/theme-and-appearance.zsh | 4 ++-- oh-my-zsh.sh | 10 +++++----- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index 4b1bb0a62..5d2c642c9 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -53,7 +53,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \ # ... unless we really want to. zstyle '*' single-ignored show -if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then +if [ "x${COMPLETION_WAITING_DOTS:-}" = "xtrue" ]; then expand-or-complete-with-dots() { echo -n "\e[31m......\e[0m" zle expand-or-complete diff --git a/lib/correction.zsh b/lib/correction.zsh index 3e1415a0b..c853ed8df 100644 --- a/lib/correction.zsh +++ b/lib/correction.zsh @@ -1,4 +1,4 @@ -if [[ "$ENABLE_CORRECTION" == "true" ]]; then +if [[ "${ENABLE_CORRECTION:-}" == "true" ]]; then alias ebuild='nocorrect ebuild' alias gist='nocorrect gist' alias heroku='nocorrect heroku' diff --git a/lib/git.zsh b/lib/git.zsh index 118841f06..f50a05134 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -17,7 +17,7 @@ parse_git_dirty() { if [[ $POST_1_7_2_GIT -gt 0 ]]; then FLAGS+='--ignore-submodules=dirty' fi - if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then + if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then FLAGS+='--untracked-files=no' fi STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) diff --git a/lib/history.zsh b/lib/history.zsh index 5de71c2d3..fa9dccc92 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -1,5 +1,5 @@ ## Command history configuration -if [ -z "$HISTFILE" ]; then +if [ -z "${HISTFILE:-}" ]; then HISTFILE=$HOME/.zsh_history fi @@ -7,7 +7,7 @@ HISTSIZE=10000 SAVEHIST=10000 # Show history -case $HIST_STAMPS in +case ${HIST_STAMPS:-} in "mm/dd/yyyy") alias history='fc -fl 1' ;; "dd.mm.yyyy") alias history='fc -El 1' ;; "yyyy-mm-dd") alias history='fc -il 1' ;; diff --git a/lib/misc.zsh b/lib/misc.zsh index 0b7cb2696..9d9f13093 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -17,6 +17,6 @@ alias please='sudo' alias afind='ack-grep -il' # only define LC_CTYPE if undefined -if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then +if [[ -z "${LC_CTYPE:-}" && -z "${LC_ALL:-}" ]]; then export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG fi diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index e1c2e2f93..af461fd90 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -7,7 +7,7 @@ # (In screen, only short_tab_title is used) # Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { - [[ "$EMACS" == *term* ]] && return + [[ "${EMACS:-}" == *term* ]] && return # if $2 is unset use $1 as default # if it is set and empty, leave it as is @@ -15,7 +15,7 @@ function title { if [[ "$TERM" == screen* ]]; then print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars - elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then + elif [[ "$TERM" == xterm* ]] || [[ "$TERM" == rxvt* ]] || [[ "$TERM" == ansi ]] || [[ "${TERM_PROGRAM:-}" == "iTerm.app" ]]; then print -Pn "\e]2;$2:q\a" #set window name print -Pn "\e]1;$1:q\a" #set icon (=tab) name fi @@ -26,7 +26,7 @@ ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" # Runs before showing the prompt function omz_termsupport_precmd { - if [[ $DISABLE_AUTO_TITLE == true ]]; then + if [[ ${DISABLE_AUTO_TITLE:-} == true ]]; then return fi @@ -35,7 +35,7 @@ function omz_termsupport_precmd { # Runs before executing the command function omz_termsupport_preexec { - if [[ $DISABLE_AUTO_TITLE == true ]]; then + if [[ ${DISABLE_AUTO_TITLE:-} == true ]]; then return fi @@ -57,7 +57,7 @@ preexec_functions+=(omz_termsupport_preexec) function omz_termsupport_cwd { # Notify Terminal.app of current directory using undocumented OSC sequence # found in OS X 10.9 and 10.10's /etc/bashrc - if [[ $TERM_PROGRAM == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then + if [[ ${TERM_PROGRAM:-} == Apple_Terminal ]] && [[ -z $INSIDE_EMACS ]]; then local PWD_URL="file://$HOSTNAME${PWD// /%20}" printf '\e]7;%s\a' "$PWD_URL" fi diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 926303ca4..2c2a420b7 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -3,7 +3,7 @@ autoload -U colors && colors export LSCOLORS="Gxfxcxdxbxegedabagacad" # Enable ls colors -if [ "$DISABLE_LS_COLORS" != "true" ] +if [ "${DISABLE_LS_COLORS:-}" != "true" ] then # Find the option for using colors in ls, depending on the version: Linux or BSD if [[ "$(uname -s)" == "NetBSD" ]]; then @@ -24,7 +24,7 @@ setopt auto_cd setopt multios setopt cdablevars -if [[ x$WINDOW != x ]] +if [[ x${WINDOW:-} != x ]] then SCREEN_NO="%B$WINDOW%b " else diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index bc7a8e496..68d033465 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,6 +1,6 @@ # Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then - env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh +if [ "${DISABLE_AUTO_UPDATE:-}" != "true" ]; then + env ZSH=$ZSH DISABLE_UPDATE_PROMPT=${DISABLE_UPDATE_PROMPT:-} zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh @@ -10,13 +10,13 @@ fpath=($ZSH/functions $ZSH/completions $fpath) # Set ZSH_CUSTOM to the path where your custom config files # and plugins exists, or else we will use the default custom/ -if [[ -z "$ZSH_CUSTOM" ]]; then +if [[ -z "${ZSH_CUSTOM:-}" ]]; then ZSH_CUSTOM="$ZSH/custom" fi # Set ZSH_CACHE_DIR to the path where cache files sould be created # or else we will use the default cache/ -if [[ -z "$ZSH_CACHE_DIR" ]]; then +if [[ -z "${ZSH_CACHE_DIR:-}" ]]; then ZSH_CACHE_DIR="$ZSH/cache/" fi @@ -55,7 +55,7 @@ else fi # Save the location of the current completion dump file. -if [ -z "$ZSH_COMPDUMP" ]; then +if [ -z "${ZSH_COMPDUMP:-}" ]; then ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" fi