mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
optimize 'alias', fixing bug #486. Also some minor optimizations in 'type'
This commit is contained in:
parent
e918851902
commit
e8da9999f6
2 changed files with 16 additions and 9 deletions
|
@ -35,11 +35,18 @@ function alias --description "Legacy function for creating shellscript functions
|
|||
return 1
|
||||
end
|
||||
|
||||
switch (type -t $name)
|
||||
case file
|
||||
set prefix command
|
||||
case builtin
|
||||
|
||||
# If we are shadowing an existing (internal or external) command, set the
|
||||
# correct prefix. If $name is different from the command in $body, we assume
|
||||
# the user knows what he/she is doing.
|
||||
|
||||
switch $body
|
||||
case $name $name\ \* $name\t\*
|
||||
if contains $name (builtin --names)
|
||||
set prefix builtin
|
||||
else if which $name >/dev/null
|
||||
set prefix command
|
||||
end
|
||||
end
|
||||
|
||||
eval "function $name; $prefix $body \$argv; end"
|
||||
|
|
|
@ -85,7 +85,7 @@ function type --description "Print the type of a command"
|
|||
functions $i
|
||||
|
||||
case type
|
||||
printf (_ 'function\n')
|
||||
echo (_ 'function')
|
||||
|
||||
case path
|
||||
echo
|
||||
|
@ -105,7 +105,7 @@ function type --description "Print the type of a command"
|
|||
printf (_ '%s is a builtin\n') $i
|
||||
|
||||
case type
|
||||
printf (_ 'builtin\n')
|
||||
echo (_ 'builtin')
|
||||
|
||||
case path
|
||||
echo
|
||||
|
@ -126,7 +126,7 @@ function type --description "Print the type of a command"
|
|||
printf (_ '%s is %s\n') $i $path
|
||||
|
||||
case type
|
||||
printf (_ 'file\n')
|
||||
echo (_ 'file')
|
||||
|
||||
case path
|
||||
echo $path
|
||||
|
|
Loading…
Reference in a new issue