* 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
check_com() {
emulate -L zsh
local -i comonly gatoo
check_com() {
emulate -L zsh
local -i comonly gatoo
if [[ $1 == '-c' ]] ; then
if [[ $1 == '-c' ]] ; then
- (( comonly = 1 ))
- shift
elif [[ $1 == '-g' ]] ; then
elif [[ $1 == '-g' ]] ; then
- (( gatoo = 1 ))
- else
- (( comonly = 0 ))
- (( gatoo = 0 ))
fi
if (( ${#argv} != 1 )) ; then
fi
if (( ${#argv} != 1 )) ; then
- printf 'usage: check_com [-c] <command>\n' >&2
+ printf 'usage: check_com [-c|-g] <command>\n' >&2
return 1
fi
if (( comonly > 0 )) ; then
return 1
fi
if (( comonly > 0 )) ; then
- [[ -n ${commands[$1]} ]] && return 0
+ (( ${+commands[$1]} )) && return 0
- 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
- if (( gatoo > 0 )) && [[ -n ${galiases[$1]} ]] ; then
+ if (( gatoo > 0 )) && (( ${+galiases[$1]} )) ; then