alias: fix indentation

Fixes #11602
This commit is contained in:
Johannes Altmanninger
2025-06-23 13:51:55 +02:00
parent ebec8c15ab
commit 096f225579
2 changed files with 9 additions and 10 deletions

View File

@@ -10,7 +10,6 @@ function alias --description 'Creates a function wrapping a command'
set -l name
set -l body
set -l prefix
if not set -q argv[1]
# Print the known aliases.
@@ -51,9 +50,9 @@ function alias --description 'Creates a function wrapping a command'
# $body starts with the same command as $name.
if test $first_word = $name
if contains $name (builtin --names)
set prefix builtin
set body "builtin $body"
else
set prefix command
set body "command $body"
end
end
set -l cmd_string (string escape -- "alias $argv")
@@ -67,8 +66,8 @@ function alias --description 'Creates a function wrapping a command'
set wraps --wraps (string escape -- $body)
end
echo "function $name $wraps --description $cmd_string; $prefix $body \$argv
end" | source # The function definition in split in two lines to ensure that a '#' can be put in the body.
# The function definition in split in two lines to ensure that a '#' can be put in the body.
echo "function $name $wraps --description $cmd_string"\n"$body \$argv"\n"end" | source
if set -q _flag_save
funcsave $name
end

View File

@@ -26,11 +26,11 @@ alias l. "ls -d .*"
# No output
alias d "'/mnt/c/Program Files (x86)/devenv.exe' /Edit"
functions d
# CHECK: # Defined via `source`
# CHECK: function d --wraps="'/mnt/c/Program Files (x86)/devenv.exe' /Edit" --description "alias d '/mnt/c/Program Files (x86)/devenv.exe' /Edit"
# CHECK: '/mnt/c/Program Files (x86)/devenv.exe' /Edit $argv
# CHECK: end
functions d | sed s,^,^,
# CHECK: ^# Defined via `source`
# CHECK: ^function d --wraps="'/mnt/c/Program Files (x86)/devenv.exe' /Edit" --description "alias d '/mnt/c/Program Files (x86)/devenv.exe' /Edit"
# CHECK: ^ '/mnt/c/Program Files (x86)/devenv.exe' /Edit $argv
# CHECK: ^end
# Use "command" to prevent recursion, and don't add --wraps to avoid accidental recursion in completion.
alias e 'e --option=value'