Skip to content

Commit

Permalink
Pick better exit statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonrichert committed Jan 22, 2021
1 parent 397f8e7 commit d1b5fb0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions functions/.znap.clone
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand All @@ -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/***(-^/)
}
Expand Down
5 changes: 1 addition & 4 deletions functions/.znap.close-fd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
# args: <file descriptor number>
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

Expand Down
2 changes: 1 addition & 1 deletion functions/.znap.rm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion functions/.znap.status
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
9 changes: 4 additions & 5 deletions functions/:znap:dirname
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ case $1 in
reply=( $repo )
return 0
fi
return 72
return 66
} "$@"
;;
d)
Expand All @@ -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

0 comments on commit d1b5fb0

Please sign in to comment.