diff --git a/share/functions/fish_add_path.fish b/share/functions/fish_add_path.fish index 6e2316dd8..1a7b2387f 100644 --- a/share/functions/fish_add_path.fish +++ b/share/functions/fish_add_path.fish @@ -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 diff --git a/tests/checks/fish_add_path.fish b/tests/checks/fish_add_path.fish index d47fef959..745bbc648 100644 --- a/tests/checks/fish_add_path.fish +++ b/tests/checks/fish_add_path.fish @@ -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