1
0
Fork 0
mirror of synced 2024-11-22 23:35:35 -05:00

Use 2 as exit code for usage errors

See https://tldp.org/LDP/abs/html/exitcodes.html
This commit is contained in:
Eric Nielsen 2021-03-19 17:13:21 -05:00
parent f7c0bbeb36
commit 65783e61ed
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
3 changed files with 17 additions and 17 deletions

View file

@ -30,12 +30,12 @@ Initialization options:
" "
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
print -u2 -PR "%F{red}${0}: Must be called from %B<%= home %>/.zimrc%b%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Must be called from %B<%= home %>/.zimrc%b%f"$'\n\n'${zusage}
return 1 return 2
fi fi
if (( ! # )); then if (( ! # )); then
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f"$'\n\n'${zusage} print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
fi fi
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
local zmodule=${1:t} zurl=${1} local zmodule=${1:t} zurl=${1}
@ -57,7 +57,7 @@ Initialization options:
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
fi fi
shift shift
zmodule=${1} zmodule=${1}
@ -74,7 +74,7 @@ Initialization options:
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
fi fi
;; ;;
esac esac
@ -114,7 +114,7 @@ Initialization options:
*) *)
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
;; ;;
esac esac
shift shift

View file

@ -25,14 +25,14 @@ Options:
local -i _zprintlevel=1 local -i _zprintlevel=1
if (( # > 2 )); then if (( # > 2 )); then
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
return 1 return 2
elif (( # > 1 )); then elif (( # > 1 )); then
case ${2} in case ${2} in
-q) _zprintlevel=0 ;; -q) _zprintlevel=0 ;;
-v) _zprintlevel=2 ;; -v) _zprintlevel=2 ;;
*) *)
print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n\n'${zusage}
return 1 return 2
;; ;;
esac esac
fi fi
@ -80,7 +80,7 @@ Options:
version) print -PR ${_zversion} ;; version) print -PR ${_zversion} ;;
*) *)
print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n\n'${zusage}
return 1 return 2
;; ;;
esac esac
} }

View file

@ -137,12 +137,12 @@ Initialization options:
" "
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
print -u2 -PR "%F{red}${0}: Must be called from %B${ZDOTDIR:-${HOME}}/.zimrc%b%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Must be called from %B${ZDOTDIR:-${HOME}}/.zimrc%b%f"$'\n\n'${zusage}
return 1 return 2
fi fi
if (( ! # )); then if (( ! # )); then
print -u2 -PR "%F{red}x ${funcfiletrace[1]}: Missing zmodule url%f"$'\n\n'${zusage} print -u2 -PR "%F{red}x ${funcfiletrace[1]}: Missing zmodule url%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
fi fi
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
local zmodule=${1:t} zurl=${1} local zmodule=${1:t} zurl=${1}
@ -164,7 +164,7 @@ Initialization options:
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
fi fi
shift shift
zmodule=${1} zmodule=${1}
@ -181,7 +181,7 @@ Initialization options:
if (( # < 2 )); then if (( # < 2 )); then
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
fi fi
;; ;;
esac esac
@ -221,7 +221,7 @@ Initialization options:
*) *)
print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}x ${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"$'\n\n'${zusage}
_zfailed=1 _zfailed=1
return 1 return 2
;; ;;
esac esac
shift shift
@ -328,7 +328,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2021-03-16 22:02:26 UTC, previous commit is 1df02c5)' print -R 'zimfw version: '${_zversion}' (built at 2021-03-19 22:13:04 UTC, previous commit is f7c0bbe)'
print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION} print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a) print -R 'System info: '$(command uname -a)
@ -401,14 +401,14 @@ Options:
local -i _zprintlevel=1 local -i _zprintlevel=1
if (( # > 2 )); then if (( # > 2 )); then
print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Too many options%f"$'\n\n'${zusage}
return 1 return 2
elif (( # > 1 )); then elif (( # > 1 )); then
case ${2} in case ${2} in
-q) _zprintlevel=0 ;; -q) _zprintlevel=0 ;;
-v) _zprintlevel=2 ;; -v) _zprintlevel=2 ;;
*) *)
print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Unknown option ${2}%f"$'\n\n'${zusage}
return 1 return 2
;; ;;
esac esac
fi fi
@ -540,7 +540,7 @@ fi
version) print -PR ${_zversion} ;; version) print -PR ${_zversion} ;;
*) *)
print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n\n'${zusage} print -u2 -PR "%F{red}${0}: Unknown action ${1}%f"$'\n\n'${zusage}
return 1 return 2
;; ;;
esac esac
} }