All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Brabec <sbrabec@suse.cz>
To: util-linux@vger.kernel.org
Subject: [PATCH 1/3] script: Split doexec() out of doshell()
Date: Tue, 10 Feb 2015 22:30:50 +0100	[thread overview]
Message-ID: <54DA788A.4080706@suse.cz> (raw)

Create doshell() that will be needed by --interactive.
---
 term-utils/script.c | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 02ba596..14a44e1 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -90,6 +90,7 @@ void getmaster(void);
 void getslave(void);
 void doinput(void);
 void dooutput(void);
+void doexec(void);
 void doshell(void);
 
 char	*shell;
@@ -508,9 +509,32 @@ dooutput(void) {
 }
 
 void
-doshell(void) {
+doexec(void) {
 	char *shname;
 
+	shname = strrchr(shell, '/');
+	if (shname)
+		shname++;
+	else
+		shname = shell;
+
+	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();
+}
+
+void
+doshell(void) {
 	getslave();
 
 	/* close things irrelevant for this process */
@@ -528,12 +552,6 @@ doshell(void) {
 
 	master = -1;
 
-	shname = strrchr(shell, '/');
-	if (shname)
-		shname++;
-	else
-		shname = shell;
-
 	/*
 	 * When invoked from within /etc/csh.login, script spawns a csh shell
 	 * that spawns programs that cannot be killed with a SIGTERM. This is
@@ -544,19 +562,7 @@ doshell(void) {
 	 */
 	signal(SIGTERM, SIG_DFL);
 
-	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();
+	doexec();
 }
 
 void
-- 
2.2.2

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: sbrabec@suse.cz
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76

                 reply	other threads:[~2015-02-10 21:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54DA788A.4080706@suse.cz \
    --to=sbrabec@suse.cz \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.