From d22f22c3b34d4a2aae12d73d529d5e28b82a58b2 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 18 Apr 2022 00:58:05 -0700 Subject: [PATCH] Print message in fish_add_path -v when a path doesnt exist (#8884) * Print message in set_fish_path -v when a path doesnt exist * Update changelog * Remove "; or continue" * use printf instead of echo, avoid localizing the path --- CHANGELOG.rst | 1 + po/en.po | 4 ++++ share/functions/fish_add_path.fish | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e2a95c3bd..226ebbf18 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -54,6 +54,7 @@ Interactive improvements - ``ulimit`` learned a number of new options for the resource limits available on Linux, FreeBSD and NetBSD, and returns a specific warning if the limit specified is not available on the active operating system (:issue:`8823`). - The ``vared`` command can now successfully edit variables named "tmp" or "prompt" (:issue:`8836`). - ``time`` now emits an error if used after the first command in a pipeline (:issue:`8841`). +- ``fish_add_path`` now prints a message for skipped non-existent paths when using the ``-v`` flag. New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/po/en.po b/po/en.po index c2f61173a..57ed0b4e4 100644 --- a/po/en.po +++ b/po/en.po @@ -62480,6 +62480,10 @@ msgstr "" msgid "Edit variable value" msgstr "Edit variable value" +#: /tmp/fish/implicit/share/functions/fish_add_path.fish:1 +msgid "Skipping non-existent path: %s\n" +msgstr "Skipping non-existent path: %s\n" + #~ msgid "%ls: No function name given\n" #~ msgstr "%ls: No function name given\n" diff --git a/share/functions/fish_add_path.fish b/share/functions/fish_add_path.fish index 6c0234426..3b2ef96f5 100644 --- a/share/functions/fish_add_path.fish +++ b/share/functions/fish_add_path.fish @@ -47,7 +47,14 @@ function fish_add_path --description "Add paths to the PATH" set -l p (builtin realpath -s -- $path 2>/dev/null) # Ignore non-existing paths - test -d "$p"; or continue + if not test -d "$p" + # path does not exist + if set -q _flag_verbose; + # print a message in verbose mode + printf (_ "Skipping non-existent path: %s\n") "$p" + end + continue + end if set -l ind (contains -i -- $p $$var) # In move-mode, we remove it from its current position and add it back.