diff options
author | Karel Zak | 2006-12-07 00:26:12 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:26:12 +0100 |
commit | df1dddf9ffcfc1e291de809c0e8b9060bfea02ee (patch) | |
tree | 03b712bddec33d05754bf59d31a75d7e2022761e /misc-utils/script.c | |
parent | Imported from util-linux-2.11y tarball. (diff) | |
download | kernel-qcow2-util-linux-df1dddf9ffcfc1e291de809c0e8b9060bfea02ee.tar.gz kernel-qcow2-util-linux-df1dddf9ffcfc1e291de809c0e8b9060bfea02ee.tar.xz kernel-qcow2-util-linux-df1dddf9ffcfc1e291de809c0e8b9060bfea02ee.zip |
Imported from util-linux-2.12 tarball.
Diffstat (limited to 'misc-utils/script.c')
-rw-r--r-- | misc-utils/script.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/misc-utils/script.c b/misc-utils/script.c index ec98ea1a4..fc913f431 100644 --- a/misc-utils/script.c +++ b/misc-utils/script.c @@ -91,6 +91,7 @@ int l; char line[] = "/dev/ptyXX"; #endif int aflg = 0; +char *cflg = NULL; int fflg = 0; int qflg = 0; int tflg = 0; @@ -135,11 +136,14 @@ main(int argc, char **argv) { } } - while ((ch = getopt(argc, argv, "afqt")) != -1) + while ((ch = getopt(argc, argv, "ac:fqt")) != -1) switch((char)ch) { case 'a': aflg++; break; + case 'c': + cflg = optarg; + break; case 'f': fflg++; break; @@ -284,7 +288,9 @@ dooutput() { void doshell() { - /*** + char *shname; + +#if 0 int t; t = open(_PATH_TTY, O_RDWR); @@ -292,7 +298,8 @@ doshell() { (void) ioctl(t, TIOCNOTTY, (char *)0); (void) close(t); } - ***/ +#endif + getslave(); (void) close(master); (void) fclose(fscript); @@ -300,11 +307,18 @@ doshell() { (void) dup2(slave, 1); (void) dup2(slave, 2); (void) close(slave); -#ifdef __linux__ - execl(shell, strrchr(shell, '/') + 1, "-i", 0); -#else - execl(shell, "sh", "-i", 0); -#endif + + shname = strrchr(shell, '/'); + if (shname) + shname++; + else + shname = shell; + + if (cflg) + execl(shell, shname, "-c", cflg, 0); + else + execl(shell, shname, "-i", 0); + perror(shell); fail(); } |