[PATCH 1/4] script: search shell from path, when necessary

Sami Kerola
2012-12-28T21:29:03Z

Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518532
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
term-utils/script.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 94a20da..983930f 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -445,11 +445,17 @@ doshell(void) {
*/
signal(SIGTERM, SIG_DFL);

- if (cflg)
- execl(shell, shname, "-c", cflg, NULL);
- else
- execl(shell, shname, "-i", NULL);
-
+ if (access(shell, X_OK) == 0) {
+ if (cflg)
+ execl(shell, shname, "-c", cflg, NULL);
+ else
+ execl(shell, shname, "-i", NULL);
+ } else {
+ if (cflg)
+ execlp(shname, "-c", cflg, NULL);
+ else
+ execlp(shname, "-i", NULL);
+ }
warn(_("failed to execute %s"), shell);
fail();
}
--
1.8.0.3