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.
This commit is contained in:
KO Myung-Hun 2015-06-11 22:16:17 +09:00
parent b27e10a32e
commit df2cf83f8b
1 changed files with 7 additions and 3 deletions

10
exec.c
View File

@ -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: