diff --git a/share/functions/alias.fish b/share/functions/alias.fish index 7df1f42ad..320ddb0e2 100644 --- a/share/functions/alias.fish +++ b/share/functions/alias.fish @@ -17,7 +17,7 @@ function alias --description 'Creates a function wrapping a command' if not set -q argv[1] # Print the known aliases. for func in (functions -n) - set -l output (functions $func | string match -r -- "^function .* --description '?alias(.*)") + set -l output (functions $func | string match -r -- "^function .* --description (?:'alias (.*)'|alias\\\\ (.*))\$") if set -q output[2] set output (string replace -r -- '^'$func'[= ]' '' $output[2]) echo alias $func (string escape -- $output[1]) diff --git a/tests/checks/alias.fish b/tests/checks/alias.fish index 569ee125e..e89c39377 100644 --- a/tests/checks/alias.fish +++ b/tests/checks/alias.fish @@ -9,6 +9,7 @@ my_alias # CHECK: foo ran alias a-2='echo "hello there"' +alias a-3='echo hello\ there' alias foo '"a b" c d e' # Bare `alias` should list the aliases we have created and nothing else @@ -16,5 +17,6 @@ alias foo '"a b" c d e' # framework and we can't predict the definition. alias | grep -Ev '^alias (fish_indent|fish_key_reader) ' # CHECK: alias a-2 'echo "hello there"' +# CHECK: alias a-3 echo\\\ hello\\\\\\\ there # CHECK: alias foo '"a b" c d e' # CHECK: alias my_alias 'foo; and echo foo ran'