tcsh/tcsh-6.20.00-postcmd.patch

55 lines
1.4 KiB
Diff

https://bugs.astron.com/view.php?id=74#c3238
Avoid trouble with e.g.
alias postcmd false
set counter=1
while ($counter > )
@ counter--
echo $counter
end
and similar scriptlets, maybe there is a better solution to
protect dowhile(), nevertheless this works.
---
tcsh-6.20.00/sh.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- tcsh-6.20.00/sh.c 2017-07-19 12:29:15.512471750 +0200
+++ tcsh-6.20.00/sh.c 2019-04-08 13:35:32.462771640 +0200
@@ -2028,6 +2028,7 @@ process(int catch)
getexit(osetexit);
omark = cleanup_push_mark();
for (;;) {
+ const struct wordent *p;
struct command *t;
int hadhist, old_pintr_disabled;
@@ -2178,7 +2179,9 @@ process(int catch)
/*
* Parse the words of the input into a parse tree.
*/
- t = syntax(paraml.next, &paraml, 0);
+ p = paraml.next;
+ t = syntax(p, &paraml, 0);
+
/*
* We cannot cleanup push here, because cd /blah; echo foo
* would rewind t on the chdir error, and free the rest of the command
@@ -2188,7 +2191,13 @@ process(int catch)
stderror(ERR_OLD);
}
- postcmd();
+ /*
+ * The potential aliasrun() might destroy the parse tree,
+ * that is that the dowhile() would be never reached again.
+ */
+ if (srchx(p->word) != TC_WHILE)
+ postcmd();
+
/*
* Execute the parse tree From: Michael Schroeder
* <mlschroe@immd4.informatik.uni-erlangen.de> was execute(t, tpgrp);