tcsh/tcsh-6.20.00-011-fix-infinite-loop-after-ctrlC.patch

48 lines
1.0 KiB
Diff

From 83c5be028419b3f27c3cc707b88fb21bfa4e1b11 Mon Sep 17 00:00:00 2001
From: zoulasc <christos@zoulas.com>
Date: Sat, 19 Oct 2019 08:52:53 -0400
Subject: [PATCH] FIx PR/113: failing -c command causes infinite loop
diff --git a/sh.c b/sh.c
index 4b5c624..dd87172 100644
--- a/sh.c
+++ b/sh.c
@@ -237,6 +237,7 @@ main(int argc, char **argv)
int nofile = 0;
volatile int nverbose = 0;
volatile int rdirs = 0;
+ volatile int exitcode = 0;
int quitit = 0;
Char *cp;
#ifdef AUTOLOGOUT
@@ -1390,6 +1391,12 @@ main(int argc, char **argv)
if (targinp) {
+ /* If this -c command caused an error before, skip processing */
+ if (reenter && arginp) {
+ exitcode = 1;
+ goto done;
+ }
+
arginp = SAVE(targinp);
/*
* we put the command into a variable
@@ -1422,6 +1429,7 @@ main(int argc, char **argv)
*/
process(setintr);
+done:
/*
* Mop-up.
*/
@@ -1443,7 +1451,7 @@ main(int argc, char **argv)
}
record();
exitstat();
- return (0);
+ return exitcode;
}
void