1
0
Fork 0

Zsh: die(): return instead of exit if interactive

This commit is contained in:
tastytea 2022-04-03 05:08:51 +02:00
parent ecc61cb747
commit cf620b0642
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 3 additions and 1 deletions

View File

@ -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}