type: Only print function path with "--path"

Fixes #7653.
This commit is contained in:
Fabian Homborg 2021-01-24 15:28:40 +01:00
parent 58df0bc051
commit baa9b21a6f
2 changed files with 8 additions and 1 deletions

View File

@ -132,7 +132,6 @@ maybe_t<int> builtin_type(parser_t &parser, io_streams_t &streams, wchar_t **arg
++found;
res = true;
if (!opts.query && !opts.type) {
streams.out.append_format(_(L"%ls is a function"), name);
auto path = function_get_definition_file(name);
if (opts.path) {
if (path) {
@ -140,6 +139,7 @@ maybe_t<int> builtin_type(parser_t &parser, io_streams_t &streams, wchar_t **arg
streams.out.append(L"\n");
}
} else if (!opts.short_output) {
streams.out.append_format(_(L"%ls is a function"), name);
streams.out.append(_(L" with definition"));
streams.out.append(L"\n");
// Function path
@ -166,6 +166,7 @@ maybe_t<int> builtin_type(parser_t &parser, io_streams_t &streams, wchar_t **arg
streams.out.append(def);
}
} else {
streams.out.append_format(_(L"%ls is a function"), name);
auto path = function_get_definition_file(name);
if (path) {
streams.out.append_format(_(L" (defined in %ls)"), path);

View File

@ -52,3 +52,9 @@ echo $status
type -q
echo $status
# CHECK: 1
type -p alias
# CHECK: {{.*}}/alias.fish
type -s alias
# CHECK: alias is a function (defined in {{.*}}/alias.fish)