From 40733ca25bd7511312b02794cdd692f65367d2a9 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 15 Aug 2022 20:01:17 +0200 Subject: [PATCH] If relative path was used, use it This was inadvertently changed in ed78fd2a5f95ed72c0745e15f53fdea6fdde1f91 Fixes #9143 --- src/path.cpp | 5 ++--- tests/checks/basic.fish | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/path.cpp b/src/path.cpp index b486f256b..04332c1ba 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -55,9 +55,8 @@ static get_path_result_t path_get_path_core(const wcstring &cmd, const wcstring_ // If the command has a slash, it must be an absolute or relative path and thus we don't bother // looking for a matching command. if (cmd.find(L'/') != wcstring::npos) { - wcstring abs_cmd = path_apply_working_directory(cmd, vars.get_pwd_slash()); - int merr = test_path(abs_cmd); - return get_path_result_t{merr, std::move(abs_cmd)}; + int merr = test_path(cmd); + return get_path_result_t{merr, cmd}; } get_path_result_t best = noent_res; diff --git a/tests/checks/basic.fish b/tests/checks/basic.fish index 617de8c58..f8af3b96f 100644 --- a/tests/checks/basic.fish +++ b/tests/checks/basic.fish @@ -568,3 +568,9 @@ $fish -c 'echo \utest' # CHECKERR: fish: Invalid token '\utest' # CHECKERR: echo \utest # CHECKERR: ^~~~~^ + +printf '%s\n' "#!/bin/sh" 'echo $0' > $tmpdir/argv0.sh +chmod +x $tmpdir/argv0.sh +cd $tmpdir +./argv0.sh +# CHECK: ./argv0.sh