From d1b5fb0a9ebdf3c2516f0e4da98271924243567e Mon Sep 17 00:00:00 2001 From: Marlon Richert Date: Fri, 22 Jan 2021 22:05:25 +0200 Subject: [PATCH] Pick better exit statuses --- functions/.znap.clone | 4 ++-- functions/.znap.close-fd | 5 +---- functions/.znap.rm | 2 +- functions/.znap.status | 2 +- functions/:znap:dirname | 9 ++++----- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/functions/.znap.clone b/functions/.znap.clone index e53b27e..4c61eeb 100644 --- a/functions/.znap.clone +++ b/functions/.znap.clone @@ -17,7 +17,7 @@ zmodload -Fa zsh/files b:zf_mkdir if (( $#repos < 1 )); then print -u2 "znap clone: no repositories found in $file" .znap.help clone - return 72 + return 78 fi local server; zstyle -s :znap:clone: default-server server || @@ -44,7 +44,7 @@ zmodload -Fa zsh/files b:zf_mkdir url=$server$1.git local dir=~znap/$url:t:r [[ -d $dir ]] && - return 72 + return 66 git -C ~znap clone --recurse-submodules -j$(ulimit -n) --depth=1 --shallow-submodules $url .znap.compile $dir/***(-^/) } diff --git a/functions/.znap.close-fd b/functions/.znap.close-fd index fa4482d..12a1040 100644 --- a/functions/.znap.close-fd +++ b/functions/.znap.close-fd @@ -3,14 +3,11 @@ # args: emulate -L zsh; setopt $_znap_opts -[[ $1 == <-> ]] || +[[ $1 == <10-> ]] || return 64 local -i fd=$1 -(( fd < 10 )) && - return 65 - { : <&$fd } 2> /dev/null || return 75 diff --git a/functions/.znap.rm b/functions/.znap.rm index 38ac195..5291338 100644 --- a/functions/.znap.rm +++ b/functions/.znap.rm @@ -13,7 +13,7 @@ zmodload -Fa zsh/parameter p:commands return 64 fi if (( ${(M@)#@:#.##} > 0 )); then - print -u2 znap rm: not a valid argument: ${(M@)@:#.##} + print -u2 "znap rm: not a valid argument: ${(M)@:#.##}" .znap.help rm return 64 fi diff --git a/functions/.znap.status b/functions/.znap.status index 3388c33..e40b948 100644 --- a/functions/.znap.status +++ b/functions/.znap.status @@ -47,7 +47,7 @@ lines=( "${(f)$(git -C $1 status -sb)}" ) local MATCH MBEGIN MEND local -aU changes=( ${(0)${${(F)lines[2,-1]}// [[:print:]]#($'\n'|)}//$'m\C-['/$'m\0\C-['} ) - changes=( ${(i@)changes[@]//(#m)('??'|'!!')/$MATCH[1]} ) + changes=( ${(@)changes[@]//(#m)('??'|'!!')/$MATCH[1]} ) local ahead_behind=${${(M)lines[1]% \[*\]}# } [[ -z $ahead_behind && -z $changes ]] && ahead_behind=$'\e[32m✓\e[39m' diff --git a/functions/:znap:dirname b/functions/:znap:dirname index 35b004e..5d5cad9 100644 --- a/functions/:znap:dirname +++ b/functions/:znap:dirname @@ -10,7 +10,7 @@ case $1 in reply=( $repo ) return 0 fi - return 72 + return 66 } "$@" ;; d) @@ -23,15 +23,14 @@ case $1 in return 0 fi done - return 72 + return 66 } "$@" ;; c) local expl tag='named-directories' group='named directory' _tags $tag - _tags && - _requested $tag expl $group && - compadd "$expl[@]" -I ']' -Q - ~znap/*(on-/:t) + _tags && _requested $tag expl $group && + compadd "$expl[@]" -I ']' -Q - ~znap/*(on-/:t) return ;; esac