1
0
Fork 0

Zsh: Use die() in functions

This commit is contained in:
tastytea 2022-04-03 06:43:18 +02:00
parent 94d92ff080
commit e7bfbe250c
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
5 changed files with 15 additions and 20 deletions

View File

@ -3,10 +3,9 @@
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
if [[ ${ARGC} -lt 2 ]]; then
print -u 2 "Usage: ${0} <old> <new>"
return 1
fi
autoload -U die
[[ ${ARGC} -lt 2 ]] && die 1 "Usage: ${0} <old> <new>"
local old="${1}"
local new="${2}"

View File

@ -3,10 +3,9 @@
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
if [[ ARGC -eq 0 ]]; then
print -u 2 "Usage: ${0} <variable> …"
return 1
fi
autoload -U die
[[ ARGC -eq 0 ]] && die 1 "Usage: ${0} <variable> …"
# Fail if we can't communicate with the daemon
[[ "$(emacsclient -e t)" == 't' ]] || return 1

View File

@ -3,10 +3,9 @@
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
if [[ ${ARGC} -ne 2 ]]; then
print -u 2 "Usage: ${0} <executable> <core dump>"
return 1
fi
autoload -U die
[[ ${ARGC} -ne 2 ]] && die 1 "Usage: ${0} <executable> <core dump>"
local exe="${1}"
local core="${2}"

View File

@ -4,10 +4,9 @@
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
if [[ ${ARGC} -ne 1 ]]; then
print -u 2 "Usage: ${0} <directory>"
return 1
fi
autoload -U die
[[ ${ARGC} -ne 1 ]] && die 1 "Usage: ${0} <directory>"
local dir="${1}"
for file in "${dir}"/*; do

View File

@ -3,10 +3,9 @@
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
if [[ ${ARGC} -eq 0 ]]; then
print -u 2 "Usage: ${0} <file> …"
return 1
fi
autoload -U die
[[ ${ARGC} -eq 0 ]] && die 1 "Usage: ${0} <file> …"
local -a putcmds
for file in "${@}"; do