From d651cdacbe2e5ca1608ec89730664a90257187c4 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 16 Jan 2019 17:29:43 -0600 Subject: [PATCH] Extend `type --path` to print path to script defining named function Expands the utility of `type -p foo` by allowing it to print the path to the script that defines `foo` when `foo` is a valid function that was sourced from a path on disk (rather than interactively defined). This does not change the behavior of `type -P`/`type --force-path`, which should have already been used if the desire was to resolve the path to an executable file (otherwise the output would have been blank if a function was shadowing an executable file of the same namea), so no backwards compatibility issues are expected. --- share/functions/type.fish | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/share/functions/type.fish b/share/functions/type.fish index b594aa3d0..e779739bc 100644 --- a/share/functions/type.fish +++ b/share/functions/type.fish @@ -56,6 +56,15 @@ function type --description 'Print the type of a command' end case type echo (_ 'function') + case path + set -l func_path (functions --details $i) + switch $func_path + case "n/a" + case "stdin" + break; + case "*" + echo $func_path + end end if test $multi != yes continue