aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions
diff options
context:
space:
mode:
Diffstat (limited to 'share/functions')
-rw-r--r--share/functions/alias.fish17
-rw-r--r--share/functions/type.fish8
2 files changed, 16 insertions, 9 deletions
diff --git a/share/functions/alias.fish b/share/functions/alias.fish
index 4b72ecd2..b6597ee2 100644
--- a/share/functions/alias.fish
+++ b/share/functions/alias.fish
@@ -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
- set prefix 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"
diff --git a/share/functions/type.fish b/share/functions/type.fish
index 94c77efa..6eb1a66f 100644
--- a/share/functions/type.fish
+++ b/share/functions/type.fish
@@ -85,10 +85,10 @@ function type --description "Print the type of a command"
functions $i
case type
- printf (_ 'function\n')
+ echo (_ 'function')
case path
- echo
+ echo
end
if test $selection != multi
@@ -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