From 1188a12dfd4d8bc669b679ac6eb1931c54292414 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 23 Sep 2020 17:23:11 +0200 Subject: [PATCH] type: Print *only* the path if given --path or --force-path This is what happens when you check your tests in the wrong tab, folks. Fixes #7345. --- src/builtin_type.cpp | 6 +++++- tests/checks/type.fish | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/builtin_type.cpp b/src/builtin_type.cpp index 0ed1c8a1d..a5a30b2e7 100644 --- a/src/builtin_type.cpp +++ b/src/builtin_type.cpp @@ -187,7 +187,11 @@ maybe_t 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 %ls\n", name, path.c_str()); + if (opts.path || opts.force_path) { + streams.out.append_format(L"%ls\n", path.c_str()); + } else { + streams.out.append_format(L"%ls is %ls\n", name, path.c_str()); + } } else if (opts.type) { streams.out.append(_(L"file\n")); break; diff --git a/tests/checks/type.fish b/tests/checks/type.fish index 3258c0f83..f5f0bbc4b 100644 --- a/tests/checks/type.fish +++ b/tests/checks/type.fish @@ -42,9 +42,9 @@ type -t realpath foobar # CHECKERR: type: Could not find {{.}}foobar{{.}} type -P test -# CHECK: test is {{.*}}/test +# CHECK: {{/.*}}test type -P ls -# CHECK: ls is {{.*}}/ls +# CHECK: {{/.*}}ls type echo $status