From 87d90665d59a87870fa7124a5136ff462a924c06 Mon Sep 17 00:00:00 2001 From: kre Date: Mon, 19 Jun 2017 03:21:31 +0000 Subject: [PATCH] Another fix from FreeBSD (this one from April 2009). When processing a string (as in eval, trap, or sh -c) don't allow trailing \n's to destroy the exit status of the last command executed. That is: sh -c 'false ' echo $? should produce 1, not 0. --- bin/sh/eval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 2317d771824d..f5ad4af98a90 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.149 2017/06/19 02:51:51 kre Exp $ */ +/* $NetBSD: eval.c,v 1.150 2017/06/19 03:21:31 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.149 2017/06/19 02:51:51 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.150 2017/06/19 03:21:31 kre Exp $"); #endif #endif /* not lint */ @@ -220,7 +220,7 @@ evalstring(char *s, int flag) while ((n = parsecmd(0)) != NEOF) { XTRACE(DBG_EVAL, ("evalstring: "), showtree(n)); - if (nflag == 0) + if (n && nflag == 0) evaltree(n, flag | EV_MORE); popstackmark(&smark); }