Zsh: die(): return instead of exit if interactive
This commit is contained in:
parent
ecc61cb747
commit
cf620b0642
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Exit with the error code of the last command and an optional error message in
|
||||
# bold pink. The error code is overridden by the first argument, if it is a
|
||||
# number. Put this in ${fpath} and load it with `autoload -U die`.
|
||||
# number. Will return instead of exit when the shell is interactive.
|
||||
# Put this in ${fpath} and load it with `autoload -U die`.
|
||||
|
||||
local errorcode=${?}
|
||||
if [[ -v 1 && ${1} =~ '^[0-9]+$' ]]; then
|
||||
|
@ -15,4 +16,5 @@ if [[ -v 1 ]]; then
|
|||
print -Pnu2 "%f%b"
|
||||
fi
|
||||
|
||||
[[ -o INTERACTIVE ]] && return ${errorcode}
|
||||
exit ${errorcode}
|
||||
|
|
Loading…
Reference in New Issue
Block a user