-/* $NetBSD: eval.c,v 1.27 1995/09/11 17:05:41 christos Exp $ */
+/* $OpenBSD: eval.c,v 1.2 1996/03/08 22:00:58 niklas Exp $ */
+/* $NetBSD: eval.c,v 1.29 1996/03/06 14:49:29 pk Exp $ */
/*-
* Copyright (c) 1993
#if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else
-static char sccsid[] = "$NetBSD: eval.c,v 1.27 1995/09/11 17:05:41 christos Exp $";
+static char sccsid[] = "$NetBSD: eval.c,v 1.29 1996/03/06 14:49:29 pk Exp $";
#endif
#endif /* not lint */
evalsubshell(n, flags);
break;
case NIF: {
- int status;
-
evaltree(n->nif.test, EV_TESTED);
- status = exitstatus;
- exitstatus = 0;
if (evalskip)
goto out;
- if (status == 0)
+ if (exitstatus == 0)
evaltree(n->nif.ifpart, flags);
else if (n->nif.elsepart)
evaltree(n->nif.elsepart, flags);
+ else
+ exitstatus = 0;
break;
}
case NWHILE:
-/* $NetBSD: parser.c,v 1.27 1995/10/19 04:14:41 christos Exp $ */
+/* $OpenBSD: parser.c,v 1.3 1996/03/08 22:01:03 niklas Exp $ */
+/* $NetBSD: parser.c,v 1.28 1996/03/05 21:04:00 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#else
-static char rcsid[] = "$NetBSD: parser.c,v 1.27 1995/10/19 04:14:41 christos Exp $";
+static char rcsid[] = "$NetBSD: parser.c,v 1.28 1996/03/05 21:04:00 christos Exp $";
#endif
#endif /* not lint */
struct jmploc jmploc;
struct jmploc *volatile savehandler;
int savelen;
+ int saveprompt;
savepbq = parsebackquote;
if (setjmp(jmploc.loc)) {
register c;
int savelen;
char *str;
+
STARTSTACKSTR(out);
- while ((c = pgetc ()) != '`') {
- if (c == '\\') {
- c = pgetc ();
+ for (;;) {
+ if (needprompt) {
+ setprompt(2);
+ needprompt = 0;
+ }
+ switch (c = pgetc()) {
+ case '`':
+ goto done;
+
+ case '\\':
+ if ((c = pgetc()) == '\n') {
+ plinno++;
+ if (doprompt)
+ setprompt(2);
+ else
+ setprompt(0);
+ }
if (c != '\\' && c != '`' && c != '$'
&& (!dblquote || c != '"'))
STPUTC('\\', out);
- }
- STPUTC(c, out);
+ break;
+
+ case '\n':
+ plinno++;
+ needprompt = doprompt;
+ break;
+
+ default:
+ break;
+ }
+ STPUTC(c, out);
}
+done:
STPUTC('\0', out);
savelen = out - stackblock();
if (savelen > 0) {
*nlpp = (struct nodelist *)stalloc(sizeof (struct nodelist));
(*nlpp)->next = NULL;
parsebackquote = oldstyle;
+
+ if (oldstyle) {
+ saveprompt = doprompt;
+ doprompt = 0;
+ }
+
n = list(0);
- if (!oldstyle && (readtoken() != TRP))
- synexpect(TRP);
+
+ if (oldstyle)
+ doprompt = saveprompt;
+ else {
+ if (readtoken() != TRP)
+ synexpect(TRP);
+ }
+
(*nlpp)->n = n;
if (oldstyle) {
/*