mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 16:52:46 +08:00
alias: Escape the first word again
See https://stackoverflow.com/questions/63115744/alias-with-spaces-and-arguments-in-fish-3
This was broken in 115892ccd2
This commit is contained in:
parent
7b5160e676
commit
84b25855b0
|
@ -57,6 +57,12 @@ function alias --description 'Creates a function wrapping a command'
|
|||
end
|
||||
end
|
||||
set -l cmd_string (string escape -- "alias $argv")
|
||||
|
||||
# We've tokenized the first word, but we need to reescape them so they won't be split apart by `source`.
|
||||
# E.g. if the first_word is "some command with spaces", that needs to be understood as one argument.
|
||||
# As $body is the rest of the tokenized read, it doesn't need to be escaped.
|
||||
set first_word (string escape -- $first_word)
|
||||
|
||||
set wrapped_cmd (string join ' ' -- $first_word $body | string escape)
|
||||
echo "function $name --wraps $wrapped_cmd --description $cmd_string; $prefix $first_word $body \$argv; end" | source
|
||||
if set -q _flag_save
|
||||
|
|
|
@ -24,3 +24,10 @@ alias | grep -Ev '^alias (fish_indent|fish_key_reader) '
|
|||
# #4756 - missing "--" argument to string causing issues with "--" options
|
||||
alias l. "ls -d .*"
|
||||
# No output
|
||||
|
||||
alias d "'/mnt/c/Program Files (x86)/devenv.exe' /Edit"
|
||||
functions d
|
||||
# CHECK: # Defined in - @ line 1
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user