tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH 5/6] script.c: gate child exit code on -e flag



---
 script.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/script.c b/script.c
index 4899d35..407793f 100644
--- a/script.c
+++ b/script.c
@@ -81,6 +81,7 @@ static int	usesleep, rawout;
 static int	quiet, flush;
 static const char *fname;
 
+static int	eflag;
 static int	isterm;
 static struct	termios tt;
 
@@ -135,10 +136,13 @@ main(int argc, char *argv[])
 		case 'r':
 			rawout = 1;
 			break;
+		case 'e':
+			eflag = 1;
+			break;
 		case '?':
 		default:
 			(void)fprintf(stderr,
-			    "Usage: %s [-c command] [-adfpqr] [file]\n",
+			    "Usage: %s [-c command] [-adefpqr] [file]\n",
 			    getprogname());
 			exit(EXIT_FAILURE);
 		}
@@ -220,7 +224,9 @@ finish(int signo)
 		}
 
 	if (die)
-		if (WIFEXITED(cstat))
+		if (!eflag)
+			done(EXIT_SUCCESS);
+		else if (WIFEXITED(cstat))
 			done(WEXITSTATUS(cstat));
 		else
 			done(128 + WTERMSIG(cstat));
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index