mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
fish_add_path: Be more informative in verbose mode
One issue with fish_add_path at the moment is that it is sometimes a bit too intransparent. You'll try to add a path, but it won't appear - was that because it wasn't a directory, or because it doesn't exist, or because it was already included? If it isn't usable after, did fish_add_path not add it because of something or did something *else* remove it? So we give more explanations - "skipping this because it's a file", "not setting anything because no paths are left to add", ...
This commit is contained in:
parent
6706b15fbc
commit
f59cdfaa8d
2 changed files with 8 additions and 0 deletions
|
@ -70,6 +70,8 @@ function fish_add_path --description "Add paths to the PATH"
|
|||
if set -q _flag_move; and not contains -- $p $newpaths
|
||||
set -a indexes $ind
|
||||
set -a newpaths $p
|
||||
else if set -q _flag_verbose
|
||||
printf (_ "Skipping already included path: %s\n") "$p"
|
||||
end
|
||||
else if not contains -- $p $newpaths
|
||||
# Without move, we only add it if it's not in.
|
||||
|
@ -99,6 +101,10 @@ function fish_add_path --description "Add paths to the PATH"
|
|||
and set $scope $var $newvar
|
||||
return 0
|
||||
else
|
||||
if set -q _flag_verbose
|
||||
# print a message in verbose mode
|
||||
printf (_ "No paths to add, not setting anything.\n") "$p"
|
||||
end
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,8 @@ function checkpath --on-variable PATH --on-variable fish_user_paths; echo CHECKP
|
|||
set PATH $PATH
|
||||
# CHECK: CHECKPATH: VARIABLE SET PATH
|
||||
fish_add_path -v $tmpdir/bin
|
||||
# CHECK: Skipping already included path: {{.*}}
|
||||
# CHECK: No paths to add, not setting anything.
|
||||
# Nothing happened, so the status failed.
|
||||
echo $status
|
||||
# CHECK: 1
|
||||
|
|
Loading…
Reference in a new issue