From df2cf83f8b02955473f0ad573fdffdf1ab1484ac Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Thu, 11 Jun 2015 22:16:17 +0900 Subject: [PATCH] scriptexec: preserve original shell/interpreter path For example, When failing to execute the script which starts with the above line, an error message does not contain information for /path/to/name. Instead, it contains only name. In addition, if /path/to/dir/, an error message contains empty string for a name of a failed script. --- exec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/exec.c b/exec.c index bccd684..b883c06 100644 --- a/exec.c +++ b/exec.c @@ -959,11 +959,15 @@ scriptexec(struct op *tp, const char **ap) } #ifdef __OS2__ /* - * Use shell/interpreter name without directory if specified - * path does not exist + * Search shell/interpreter name without directory in PATH + * if specified path does not exist */ if (ksh_vstrchr_dirsep(sh) && !search_path(sh, path, X_OK, NULL)) - sh = _getname(sh); + { + cp = search_path(_getname(sh), path, X_OK, NULL); + if (cp) + sh = cp; + } #endif goto nomagic; noshebang: