Use ret local variable only when needed

This commit is contained in:
Julien Nicoulaud 2011-07-31 18:43:32 +02:00
parent 9825e0e601
commit 1eded9e421
1 changed files with 6 additions and 9 deletions

15
_ack
View File

@ -45,6 +45,7 @@
_ack() { _ack() {
local curcontext="$curcontext" state line cmds ret=1 local curcontext="$curcontext" state line cmds ret=1
# FIXME Add directly --type/--notype
_arguments -C \ _arguments -C \
'(- 1 *)--version[Display version and copyright information.]' \ '(- 1 *)--version[Display version and copyright information.]' \
'(- 1 *)--help[Print a short help statement.]' \ '(- 1 *)--help[Print a short help statement.]' \
@ -114,13 +115,11 @@ _ack() {
} }
_ack_patterns() { _ack_patterns() {
local ret=1 _message -e patterns 'pattern'
_message -e patterns 'pattern' && ret=0
return ret
} }
_ack_colors() { _ack_colors() {
local ret=1 colors local colors
colors=( colors=(
'black' 'on_black' 'black' 'on_black'
'red' 'on_red' 'red' 'on_red'
@ -140,8 +139,7 @@ _ack_colors() {
'reverse' 'reverse'
'concealed' 'concealed'
) )
_describe -t 'colors' "color" colors && ret=0 _describe -t 'colors' "color" colors
return ret
} }
_ack_type_defs() { _ack_type_defs() {
@ -155,11 +153,10 @@ _ack_type_defs() {
} }
_ack_types() { _ack_types() {
local ret=1 types local types
types=(${${(S)${(f)${${"$(_call_program types $words[1] --help=types)"}#*--\[no\]}}#*no\]}/ ##/:}) types=(${${(S)${(f)${${"$(_call_program types $words[1] --help=types)"}#*--\[no\]}}#*no\]}/ ##/:})
types+=("no"$types) types+=("no"$types)
_describe -t "types" "type" types && ret=0 _describe -t "types" "type" types
return ret
} }
_ack "$@" _ack "$@"