From ebd9d165348f511fa1082f9a4c0ce341e277f131 Mon Sep 17 00:00:00 2001 From: Thilo Six Date: Sat, 30 Apr 2016 13:39:05 +0200 Subject: [PATCH] zshrc: check_com() fixed and zshified * FIX: in the elif a shift was missing * MOD: use '(( ${+' instead of '[[ -n ${' One thing though: I tried to verify since when Zsh supports that. Currently i do not know where to get that from. * FIX: add -g to help message --- etc/zsh/zshrc | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 14cc648..c03b614 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -450,36 +450,35 @@ fi check_com() { emulate -L zsh local -i comonly gatoo + comonly=0 + gatoo=0 if [[ $1 == '-c' ]] ; then - (( comonly = 1 )) - shift + comonly=1 + shift 1 elif [[ $1 == '-g' ]] ; then - (( gatoo = 1 )) - else - (( comonly = 0 )) - (( gatoo = 0 )) + gatoo=1 + shift 1 fi if (( ${#argv} != 1 )) ; then - printf 'usage: check_com [-c] \n' >&2 + printf 'usage: check_com [-c|-g] \n' >&2 return 1 fi if (( comonly > 0 )) ; then - [[ -n ${commands[$1]} ]] && return 0 + (( ${+commands[$1]} )) && return 0 return 1 fi - if [[ -n ${commands[$1]} ]] \ - || [[ -n ${functions[$1]} ]] \ - || [[ -n ${aliases[$1]} ]] \ - || [[ -n ${reswords[(r)$1]} ]] ; then - + if (( ${+commands[$1]} )) \ + || (( ${+functions[$1]} )) \ + || (( ${+aliases[$1]} )) \ + || (( ${+reswords[(r)$1]} )) ; then return 0 fi - if (( gatoo > 0 )) && [[ -n ${galiases[$1]} ]] ; then + if (( gatoo > 0 )) && (( ${+galiases[$1]} )) ; then return 0 fi -- 2.1.4