summaryrefslogtreecommitdiffstats
path: root/term-utils/script.c
diff options
context:
space:
mode:
authorSami Kerola2012-12-28 22:23:40 +0100
committerKarel Zak2013-01-09 13:37:01 +0100
commitb4ff2f54d794be5ca54cd40bcbbce2096f22d177 (patch)
treeeb0c9f7ef79851ee5081bf5c3306d73272100986 /term-utils/script.c
parentflock: improve usage strings (diff)
downloadkernel-qcow2-util-linux-b4ff2f54d794be5ca54cd40bcbbce2096f22d177.tar.gz
kernel-qcow2-util-linux-b4ff2f54d794be5ca54cd40bcbbce2096f22d177.tar.xz
kernel-qcow2-util-linux-b4ff2f54d794be5ca54cd40bcbbce2096f22d177.zip
script: search shell from path, when necessary
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518532 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'term-utils/script.c')
-rw-r--r--term-utils/script.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/term-utils/script.c b/term-utils/script.c
index 94a20da6c..983930f5c 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();
}