mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 13:58:00 +00:00
Standardized error messages.
This commit is contained in:
parent
28da8f916b
commit
95c29bada8
@ -19,7 +19,7 @@ TRAP_SIGNALS=(
|
||||
# Adds a function to a list to be called when a trap is triggered.
|
||||
function add-zsh-trap() {
|
||||
if (( $# < 2 )); then
|
||||
print "Usage: $0 type function"
|
||||
print "usage: $0 type function"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
2
init.zsh
2
init.zsh
@ -3,7 +3,7 @@
|
||||
# Check for the minimum supported version.
|
||||
min_zsh_version='4.3.10'
|
||||
if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
|
||||
print "omz: The minimum supported Zsh version is $min_zsh_version."
|
||||
print "omz: too old shell version detected, minimum required: $min_zsh_version"
|
||||
fi
|
||||
unset min_zsh_version
|
||||
|
||||
|
@ -4,12 +4,14 @@ local file_name
|
||||
local extract_dir
|
||||
|
||||
if (( $# == 0 )); then
|
||||
print "Usage: extract [-option] [file ...]"
|
||||
print
|
||||
print "Options:"
|
||||
print " -r, --remove Remove archive."
|
||||
print
|
||||
print "Report bugs to <sorin.ionescu@gmail.com>."
|
||||
cat >&2 <<EOF
|
||||
usage: $0 [-option] [file ...]
|
||||
|
||||
options:
|
||||
-r, --remove remove archive
|
||||
|
||||
Report bugs to <sorin.ionescu@gmail.com>.
|
||||
EOF
|
||||
fi
|
||||
|
||||
remove_archive=1
|
||||
@ -20,7 +22,7 @@ fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
print "extract: '$1' is not a valid file" 1>&2
|
||||
print "$0: file not valid: $1" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
@ -56,7 +58,7 @@ while (( $# > 0 )); do
|
||||
cd ..
|
||||
;;
|
||||
(*)
|
||||
print "extract: '$1' cannot be extracted" 1>&2
|
||||
print "$0: cannot extract: $1" >&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
@ -1,12 +1,14 @@
|
||||
local verbose
|
||||
|
||||
if (( $# == 0 )); then
|
||||
print "Usage: extract [-option] [file ...]"
|
||||
print
|
||||
print "Options:"
|
||||
print " -v, --verbose Verbose archive listing."
|
||||
print
|
||||
print "Report bugs to <sorin.ionescu@gmail.com>."
|
||||
cat >&2 <<EOF
|
||||
usage: $0 [-option] [file ...]
|
||||
|
||||
options:
|
||||
-v, --verbose verbose archive listing
|
||||
|
||||
Report bugs to <sorin.ionescu@gmail.com>.
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [[ "$1" == "-v" ]] || [[ "$1" == "--verbose" ]]; then
|
||||
@ -16,7 +18,7 @@ fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
print "extract: '$1' is not a valid file" 1>&2
|
||||
print "$0: file not valid: $1" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
@ -35,7 +37,7 @@ while (( $# > 0 )); do
|
||||
(*.rar) unrar ${${verbose:+v}:-l} "$1" ;;
|
||||
(*.7z) 7za l "$1" ;;
|
||||
(*)
|
||||
print "ls-archive: '$1' cannot be listed" 1>&2
|
||||
print "$0: cannot list: $1" >&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
@ -30,11 +30,11 @@ if [[ -n "$url" ]]; then
|
||||
"$BROWSER" "$url"
|
||||
return 0
|
||||
else
|
||||
print "fatal: Browser not set or set to a non-existent browser." >&2
|
||||
print "$0: browser not set or set to a non-existent browser" >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print "fatal: Not a Git repository or origin remote not set." >&2
|
||||
print "$0: not a Git repository or remote origin not set" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -64,7 +64,7 @@ function _git-info-abort() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
cat > /dev/stderr <<END
|
||||
cat >&2 <<EOF
|
||||
|
||||
|
||||
Gathering status for certain repositories is time intensive.
|
||||
@ -74,7 +74,7 @@ for this repository.
|
||||
To revert, execute:
|
||||
git-info on
|
||||
|
||||
END
|
||||
EOF
|
||||
|
||||
unset _git_info_executing
|
||||
git config --bool prompt.showinfo false
|
||||
@ -156,7 +156,7 @@ function git-info() {
|
||||
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
|
||||
git config --bool prompt.showinfo false
|
||||
else
|
||||
print "Usage: $0 [ on | off ]"
|
||||
print "usage: $0 [ on | off ]" >&2
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
@ -149,7 +149,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
|
||||
{
|
||||
# Load Zsh module zsh/zleparameter, needed to override user defined widgets.
|
||||
zmodload zsh/zleparameter 2>/dev/null || {
|
||||
print 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2
|
||||
print 'history-substring-search: failed loading: zsh/zleparameter' >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
|
||||
# Default: unhandled case.
|
||||
*) print "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
|
||||
*) print "history-substring-search: unhandled ZLE widget: $cur_widget" >&2 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Perl Global Substitution
|
||||
if (( $# < 2 )); then
|
||||
print "Usage: $0 find replace [file ...]" >&2
|
||||
print "usage: $0 find replace [file ...]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Perl grep since 'grep -P' is terrible.
|
||||
if (( $# < 1 )) ; then
|
||||
print "Usage: $0 pattern [file ...]" >&2
|
||||
print "usage: $0 pattern [file ...]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
local config_file="$HOME/.wakeonlan/$1"
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
print "$0: $1: There is no such device file." >&2
|
||||
print "$0: no such device file: $1" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( ! $+commands[wakeonlan] )); then
|
||||
print "$0: Can't find wakeonlan. Is it installed?" >&2
|
||||
print "$0: command not found: wakeonlan" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user