small tweak to alias.fish: always add some prefix if in danger of infinite recursion

This commit is contained in:
Jan Kanis 2013-02-19 22:58:55 +01:00
parent e7c1cb7185
commit 2f43584727

View file

@ -36,15 +36,14 @@ function alias --description "Legacy function for creating shellscript functions
end end
# If we are shadowing an existing (internal or external) command, set the # Prevent the alias from immediately running into an infinite recursion if
# correct prefix. If $name is different from the command in $body, we assume # $body starts with the same command as $name.
# the user knows what he/she is doing.
switch $body switch $body
case $name $name\ \* $name\t\* case $name $name\ \* $name\t\*
if contains $name (builtin --names) if contains $name (builtin --names)
set prefix builtin set prefix builtin
else if which $name >/dev/null else
set prefix command set prefix command
end end
end end