mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 05:37:36 +08:00
Make more of the functions in share/functions print error messages to stderr
This commit is contained in:
parent
84bd1715d8
commit
a770ff144e
|
@ -5,7 +5,7 @@ function __fish_md5
|
|||
if test $argv[1] = -s
|
||||
echo (echo $argv[2] | md5sum | string split ' ')[1]
|
||||
else
|
||||
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv
|
||||
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv >&2
|
||||
end
|
||||
else
|
||||
echo (md5sum $argv[1] | string split ' ')[1]
|
||||
|
@ -17,7 +17,7 @@ function __fish_md5
|
|||
if test $argv[1] = -s
|
||||
md5 -s $argv[2]
|
||||
else
|
||||
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv
|
||||
printf (_ "%s: Too many arguments %s\n") fish_md5 $argv >&2
|
||||
end
|
||||
else
|
||||
md5 -q $argv[1]
|
||||
|
|
|
@ -37,7 +37,7 @@ function __fish_print_help --description "Print help message for the specified f
|
|||
set -a format -rLL={$cols}n
|
||||
end
|
||||
else
|
||||
echo fish: (_ "Cannot format help; no parser found")
|
||||
echo fish: (_ "Cannot format help; no parser found") >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
|
|||
|
||||
if contains -- -h $argv
|
||||
or contains -- --help $argv
|
||||
echo "Sorry but this function doesn't support -h or --help"
|
||||
echo "Sorry but this function doesn't support -h or --help" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -10,21 +10,21 @@ function _validate_int --no-scope-shadowing
|
|||
|
||||
if not string match -qr '^-?\d+$' -- $_flag_value
|
||||
set -l msg (_ "%s: Value '%s' for flag '%s' is not an integer\n")
|
||||
printf $msg $_argparse_cmd $_flag_value $_flag_name
|
||||
printf $msg $_argparse_cmd $_flag_value $_flag_name >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
if set -q _flag_min
|
||||
and test $_flag_value -lt $_flag_min
|
||||
set -l msg (_ "%s: Value '%s' for flag '%s' less than min allowed of '%s'\n")
|
||||
printf $msg $_argparse_cmd $_flag_value $_flag_name $_flag_min
|
||||
printf $msg $_argparse_cmd $_flag_value $_flag_name $_flag_min >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
if set -q _flag_max
|
||||
and test $_flag_value -gt $_flag_max
|
||||
set -l msg (_ "%s: Value '%s' for flag '%s' greater than max allowed of '%s'\n")
|
||||
printf $msg $_argparse_cmd $_flag_value $_flag_name $_flag_max
|
||||
printf $msg $_argparse_cmd $_flag_value $_flag_name $_flag_max >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ function cd --description "Change directory"
|
|||
set -l MAX_DIR_HIST 25
|
||||
|
||||
if test (count $argv) -gt (test "$argv[1]" = "--" && echo 2 || echo 1)
|
||||
printf "%s\n" (_ "Too many args for cd command")
|
||||
printf "%s\n" (_ "Too many args for cd command") >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ function cdh --description "Menu based cd command"
|
|||
set -l dirc (count $uniq_dirs)
|
||||
if test $dirc -gt (count $letters)
|
||||
set -l msg (_ 'This should not happen. Have you changed the cd function?')
|
||||
printf "$msg\n"
|
||||
printf "$msg\n" >&2
|
||||
set -l msg (_ 'There are %s unique dirs in your history but I can only handle %s')
|
||||
printf "$msg\n" $dirc (count $letters)
|
||||
printf "$msg\n" $dirc (count $letters) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
@ -77,11 +77,11 @@ function cdh --description "Menu based cd command"
|
|||
cd $uniq_dirs[$choice]
|
||||
return
|
||||
else
|
||||
printf "$msg\n" $dirc $choice
|
||||
printf "$msg\n" $dirc $choice >&2
|
||||
return 1
|
||||
end
|
||||
else
|
||||
printf "$msg\n" $dirc $choice
|
||||
printf "$msg\n" $dirc $choice >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ function fish_update_completions --description "Update man-page based completion
|
|||
if set -l python (__fish_anypython)
|
||||
$python $update_args
|
||||
else
|
||||
printf "%s\n" (_ "python executable not found")
|
||||
printf "%s\n" (_ "python executable not found") >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
||||
if contains -- -h $argv
|
||||
or contains -- --help $argv
|
||||
echo "Sorry but this function doesn't support -h or --help"
|
||||
echo "Sorry but this function doesn't support -h or --help" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ function funced --description 'Edit function definition'
|
|||
set -l editor_cmd
|
||||
echo $editor | read -ta editor_cmd
|
||||
if not type -q -f "$editor_cmd[1]"
|
||||
echo (_ "funced: The value for \$EDITOR '$editor' could not be used because the command '$editor_cmd[1]' could not be found")
|
||||
echo (_ "funced: The value for \$EDITOR '$editor' could not be used because the command '$editor_cmd[1]' could not be found") >&2
|
||||
set editor fish
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ function help --description 'Show help for the fish shell'
|
|||
if string match -q string $argv[1]
|
||||
set fish_help_item (string join '-' $argv[1] $argv[2])
|
||||
else
|
||||
echo "help: Expected at most 1 args, got 2"
|
||||
echo "help: Expected at most 1 args, got 2" >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
@ -93,8 +93,8 @@ function help --description 'Show help for the fish shell'
|
|||
end
|
||||
|
||||
if not set -q fish_browser[1]
|
||||
printf (_ '%s: Could not find a web browser.\n') help
|
||||
printf (_ 'Please try `BROWSER=some_browser help`, `man fish-doc`, or `man fish-tutorial`.\n\n')
|
||||
printf (_ '%s: Could not find a web browser.\n') help >&2
|
||||
printf (_ 'Please try `BROWSER=some_browser help`, `man fish-doc`, or `man fish-tutorial`.\n\n') >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ function nextd --description "Move forward in the directory history"
|
|||
if test $argv[1] -ge 0 2>/dev/null
|
||||
set times $argv[1]
|
||||
else
|
||||
printf (_ "%s: The number of positions to skip must be a non-negative integer\n") nextd
|
||||
printf (_ "%s: The number of positions to skip must be a non-negative integer\n") nextd >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ if not command -sq open
|
|||
end
|
||||
|
||||
if not set -q argv[1]
|
||||
printf (_ "%ls: Expected at least %d args, got only %d\n") open 1 0
|
||||
printf (_ "%ls: Expected at least %d args, got only %d\n") open 1 0 >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ if not command -sq open
|
|||
disown $last_pid 2>/dev/null
|
||||
end
|
||||
else
|
||||
echo (_ 'No open utility found. Try installing "xdg-open" or "xdg-utils".')
|
||||
echo (_ 'No open utility found. Try installing "xdg-open" or "xdg-utils".') >&2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ function prevd --description "Move back in the directory history"
|
|||
if test $argv[1] -ge 0 2>/dev/null
|
||||
set times $argv[1]
|
||||
else
|
||||
printf (_ "%s: The number of positions to skip must be a non-negative integer\n") nextd
|
||||
printf (_ "%s: The number of positions to skip must be a non-negative integer\n") prevd >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ function pushd --description 'Push directory to stack'
|
|||
if not set -q argv[1]
|
||||
# check that the stack isn't empty
|
||||
if not set -q dirstack[1]
|
||||
echo "pushd: no other directory"
|
||||
echo "pushd: no other directory" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ function pushd --description 'Push directory to stack'
|
|||
if test -n "$rot_r"
|
||||
# check the rotation in range
|
||||
if test $rot_r -ge (count $stack)
|
||||
echo "pushd: -$rot_r: directory stack index out of range"
|
||||
echo "pushd: -$rot_r: directory stack index out of range" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ function pushd --description 'Push directory to stack'
|
|||
|
||||
# check the rotation in range
|
||||
if test $rot_l -ge (count $stack)
|
||||
echo "pushd: +$rot_l: directory stack index out of range"
|
||||
echo "pushd: +$rot_l: directory stack index out of range" >&2
|
||||
return 1
|
||||
else
|
||||
# rotate stack unless rot_l is 0
|
||||
|
|
|
@ -49,7 +49,7 @@ function realpath -d "return an absolute path without symlinks"
|
|||
end
|
||||
|
||||
if not set -q argv[1]
|
||||
printf (_ "%ls: Expected at least %d args, got only %d\n") realpath 1 0
|
||||
printf (_ "%ls: Expected at least %d args, got only %d\n") realpath 1 0 >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ if not command -sq seq
|
|||
set step $argv[2]
|
||||
set to $argv[3]
|
||||
case '*'
|
||||
printf (_ "%s: Expected 1, 2 or 3 arguments, got %d\n") seq (count $argv)
|
||||
printf (_ "%s: Expected 1, 2 or 3 arguments, got %d\n") seq (count $argv) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
for i in $from $step $to
|
||||
if not string match -rq -- '^-?[0-9]*([0-9]*|\.[0-9]+)$' $i
|
||||
printf (_ "%s: '%s' is not a number\n") seq $i
|
||||
printf (_ "%s: '%s' is not a number\n") seq $i >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ function vared --description "Edit variable value"
|
|||
return 0
|
||||
|
||||
case '-*'
|
||||
printf (_ "%s: Unknown option %s\n") vared $argv
|
||||
printf (_ "%s: Unknown option %s\n") vared $argv >&2
|
||||
return 1
|
||||
|
||||
case '*'
|
||||
|
@ -30,10 +30,10 @@ function vared --description "Edit variable value"
|
|||
-c "$$argv" \
|
||||
$argv
|
||||
else
|
||||
printf (_ '%s: %s is an array variable. Use %svared%s %s[n]%s to edit the n:th element of %s\n') vared $argv (set_color $fish_color_command; echo) (set_color $fish_color_normal; echo) $argv (set_color normal; echo) $argv
|
||||
printf (_ '%s: %s is an array variable. Use %svared%s %s[n]%s to edit the n:th element of %s\n') vared $argv (set_color $fish_color_command; echo) (set_color $fish_color_normal; echo) $argv (set_color normal; echo) $argv >&2
|
||||
end
|
||||
end
|
||||
else
|
||||
printf (_ '%s: Expected exactly one argument, got %s.\n\nSynopsis:\n\t%svared%s VARIABLE\n') vared (count $argv) (set_color $fish_color_command; echo) (set_color $fish_color_normal; echo)
|
||||
printf (_ '%s: Expected exactly one argument, got %s.\n\nSynopsis:\n\t%svared%s VARIABLE\n') vared (count $argv) (set_color $fish_color_command; echo) (set_color $fish_color_normal; echo) >&2
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user