diff --git a/helper.zsh b/helper.zsh index ad06e694..b803b6cf 100644 --- a/helper.zsh +++ b/helper.zsh @@ -58,7 +58,7 @@ function omodload { print "$0: no such module: $omodule" >&2 continue else - if [[ -f "$OMZ/modules/$omodule/init.zsh" ]]; then + if [[ -s "$OMZ/modules/$omodule/init.zsh" ]]; then source "$OMZ/modules/$omodule/init.zsh" fi diff --git a/init.zsh b/init.zsh index 2af9e858..42c395ad 100644 --- a/init.zsh +++ b/init.zsh @@ -47,7 +47,7 @@ fi # Compile the completion dump, to increase startup speed. dump_file="$HOME/.zcompdump" -if [[ "$dump_file" -nt "${dump_file}.zwc" || ! -f "${dump_file}.zwc" ]]; then +if [[ "$dump_file" -nt "${dump_file}.zwc" || ! -s "${dump_file}.zwc" ]]; then zcompile "$dump_file" fi unset dump_file diff --git a/modules/alias/init.zsh b/modules/alias/init.zsh index 555d4b42..9f06cace 100644 --- a/modules/alias/init.zsh +++ b/modules/alias/init.zsh @@ -16,7 +16,7 @@ if is-callable 'dircolors'; then alias ls='ls --group-directories-first' if zstyle -t ':omz:alias:ls' color; then - if [[ -f "$HOME/.dir_colors" ]]; then + if [[ -s "$HOME/.dir_colors" ]]; then eval "$(dircolors "$HOME/.dir_colors")" else eval "$(dircolors)" diff --git a/modules/archive/functions/extract b/modules/archive/functions/extract index a18f5068..af7ed25a 100644 --- a/modules/archive/functions/extract +++ b/modules/archive/functions/extract @@ -28,7 +28,7 @@ if [[ "$1" == "-r" || "$1" == "--remove" ]]; then fi while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then + if [[ ! -s "$1" ]]; then print "$0: file not valid: $1" >&2 shift continue diff --git a/modules/archive/functions/ls-archive b/modules/archive/functions/ls-archive index fb7a503d..e8727fa1 100644 --- a/modules/archive/functions/ls-archive +++ b/modules/archive/functions/ls-archive @@ -24,7 +24,7 @@ if [[ "$1" == "-v" || "$1" == "--verbose" ]]; then fi while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then + if [[ ! -s "$1" ]]; then print "$0: file not valid: $1" >&2 shift continue diff --git a/modules/command-not-found/init.zsh b/modules/command-not-found/init.zsh index ac9468bd..d4a1e852 100644 --- a/modules/command-not-found/init.zsh +++ b/modules/command-not-found/init.zsh @@ -5,7 +5,7 @@ # Joseph Jon Booker # -if [[ -f /etc/zsh_command_not_found ]]; then +if [[ -s /etc/zsh_command_not_found ]]; then source /etc/zsh_command_not_found fi diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index dd8cdc73..07211645 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -125,7 +125,7 @@ zstyle ':completion:*:*:ogg123:*' file-patterns '*.(ogg|OGG|flac):ogg\ files *(- zstyle ':completion:*:*:mocp:*' file-patterns '*.(wav|WAV|mp3|MP3|ogg|OGG|flac):ogg\ files *(-/):directories' # Mutt -if [[ -f ~/.mutt/aliases ]]; then +if [[ -s ~/.mutt/aliases ]]; then zstyle ':completion:*:*:mutt:*' menu yes select zstyle ':completion:*:mutt:*' users ${${${(f)"$(<~/.mutt/aliases)"}#alias[[:space:]]}%%[[:space:]]*} fi diff --git a/modules/gpg-agent/init.zsh b/modules/gpg-agent/init.zsh index 70e68e3c..35c5eda8 100644 --- a/modules/gpg-agent/init.zsh +++ b/modules/gpg-agent/init.zsh @@ -19,7 +19,7 @@ function _gpg-agent-start { } # Source GPG agent settings, if applicable. -if [[ -f "${_gpg_env}" ]]; then +if [[ -s "${_gpg_env}" ]]; then source "${_gpg_env}" > /dev/null ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'gpg-agent' || { _gpg-agent-start diff --git a/modules/node/init.zsh b/modules/node/init.zsh index 07d0baac..b70f277e 100644 --- a/modules/node/init.zsh +++ b/modules/node/init.zsh @@ -6,7 +6,7 @@ # cache_file="${0:h}/cache.zsh" -if [[ ! -f "$cache_file" ]]; then +if [[ ! -s "$cache_file" ]]; then if (( $+commands[npm] )); then # npm is slow; cache its output. npm completion >! "$cache_file" 2> /dev/null diff --git a/modules/perl/init.zsh b/modules/perl/init.zsh index b807bb69..55940172 100644 --- a/modules/perl/init.zsh +++ b/modules/perl/init.zsh @@ -21,7 +21,7 @@ if [[ "$OSTYPE" == darwin* ]]; then perl_path="$HOME/Library/Perl/5.12" if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then manpath=("$perl_path/man" $manpath) - if [[ ! -f "$cache_file" ]]; then + if [[ ! -s "$cache_file" ]]; then perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file" source "$cache_file" else diff --git a/modules/ssh-agent/init.zsh b/modules/ssh-agent/init.zsh index 375b83bb..7163869f 100644 --- a/modules/ssh-agent/init.zsh +++ b/modules/ssh-agent/init.zsh @@ -51,7 +51,7 @@ zstyle -b ':omz:module:ssh-agent' forwarding '_ssh_agent_forwarding' if is-true "${_ssh_agent_forwarding}" && [[ -n "$SSH_AUTH_SOCK" ]]; then # Add a nifty symlink for screen/tmux if agent forwarding. [[ -L "$SSH_AUTH_SOCK" ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen -elif [ -f "${_ssh_agent_env}" ]; then +elif [[ -s "${_ssh_agent_env}" ]]; then # Source SSH settings, if applicable. source "${_ssh_agent_env}" > /dev/null ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'ssh-agent$' || { diff --git a/modules/wakeonlan/functions/wake b/modules/wakeonlan/functions/wake index 7e03efaa..b8a6ab5d 100644 --- a/modules/wakeonlan/functions/wake +++ b/modules/wakeonlan/functions/wake @@ -7,8 +7,8 @@ # local config_file="$HOME/.wakeonlan/$1" -if [[ ! -f "$config_file" ]]; then - print "$0: no such device file: $1" >&2 +if [[ ! -s "$config_file" ]]; then + print "$0: invalid device file: $1" >&2 return 1 fi diff --git a/modules/z/init.zsh b/modules/z/init.zsh index 50869195..4175cde5 100644 --- a/modules/z/init.zsh +++ b/modules/z/init.zsh @@ -15,7 +15,7 @@ _z_prefixes=( for _z_prefix in "$_z_prefixes[@]"; do _z_sh="${_z_prefix}/etc/profile.d/z.sh" - if [[ -f "$_z_sh" ]]; then + if [[ -s "$_z_sh" ]]; then source "$_z_sh" break fi