Skip to content

Commit

Permalink
Check for non-empty files, not just existance
Browse files Browse the repository at this point in the history
  • Loading branch information
sorin-ionescu committed May 5, 2012
1 parent 3ed8265 commit e5ec94a
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion helper.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/alias/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion modules/archive/functions/extract
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/archive/functions/ls-archive
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/command-not-found/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Joseph Jon Booker <[email protected]>
#

if [[ -f /etc/zsh_command_not_found ]]; then
if [[ -s /etc/zsh_command_not_found ]]; then
source /etc/zsh_command_not_found
fi

2 changes: 1 addition & 1 deletion modules/completion/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/gpg-agent/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/node/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/perl/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/ssh-agent/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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$' || {
Expand Down
4 changes: 2 additions & 2 deletions modules/wakeonlan/functions/wake
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion modules/z/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5ec94a

Please sign in to comment.