From e5ec94af427b33567942b32fd523d1f716ef1d64 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 16 Apr 2012 14:21:29 -0400 Subject: [PATCH] Check for non-empty files, not just existance --- helper.zsh | 2 +- init.zsh | 2 +- modules/alias/init.zsh | 2 +- modules/archive/functions/extract | 2 +- modules/archive/functions/ls-archive | 2 +- modules/command-not-found/init.zsh | 2 +- modules/completion/init.zsh | 2 +- modules/gpg-agent/init.zsh | 2 +- modules/node/init.zsh | 2 +- modules/perl/init.zsh | 2 +- modules/ssh-agent/init.zsh | 2 +- modules/wakeonlan/functions/wake | 4 ++-- modules/z/init.zsh | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/helper.zsh b/helper.zsh index ad06e69..b803b6c 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 2af9e85..42c395a 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 555d4b4..9f06cac 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 a18f506..af7ed25 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 fb7a503..e8727fa 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 ac9468b..d4a1e85 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 dd8cdc7..0721164 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 70e68e3..35c5eda 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 07d0baa..b70f277 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 b807bb6..5594017 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 375b83b..7163869 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 7e03efa..b8a6ab5 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 5086919..4175cde 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