mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
add more alias unit tests
A recent regression to the `alias` command points out the need for more unit tests of its behavior. I also decided to use it as an opportunity to normalize the output of just `alias` to list aliases.
This commit is contained in:
@@ -17,9 +17,11 @@ 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 .*)'" | string split \n)
|
||||
set -q output[2]
|
||||
and echo $output[2]
|
||||
set -l output (functions $func | string match -r -- "^function .* --description 'alias (.*)'")
|
||||
if set -q output[2]
|
||||
set output (string replace -r '^'$func'[= ]' '' -- $output[2])
|
||||
echo alias $func (string escape -- $output[1])
|
||||
end
|
||||
end
|
||||
return 0
|
||||
else if not set -q argv[2]
|
||||
|
||||
Reference in New Issue
Block a user