sh: Honor -n while processing -c string.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 21 Aug 2011 19:52:25 +0000 (12:52 -0700)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 21 Aug 2011 20:49:18 +0000 (13:49 -0700)
Obtained-from:   FreeBSD 222676

bin/sh/eval.c
tools/regression/bin/sh/execution/set-n4.0 [new file with mode: 0644]

index 7f9ae8c..1de8c31 100644 (file)
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  * @(#)eval.c  8.9 (Berkeley) 6/8/95
- * $FreeBSD: src/bin/sh/eval.c,v 1.105 2011/05/21 22:03:06 jilles Exp $
+ * $FreeBSD: src/bin/sh/eval.c,v 1.106 2011/06/04 11:28:42 jilles Exp $
  */
 
 #include <sys/time.h>
@@ -166,7 +166,7 @@ evalstring(char *s, int flags)
        setstackmark(&smark);
        setinputstring(s, 1);
        while ((n = parsecmd(0)) != NEOF) {
-               if (n != NULL) {
+               if (n != NULL && !nflag) {
                        if (flags_exit && preadateof())
                                evaltree(n, flags | EV_EXIT);
                        else
diff --git a/tools/regression/bin/sh/execution/set-n4.0 b/tools/regression/bin/sh/execution/set-n4.0
new file mode 100644 (file)
index 0000000..29bf3df
--- /dev/null
@@ -0,0 +1,3 @@
+# $FreeBSD: src/tools/regression/bin/sh/execution/set-n4.0,v 1.1 2011/06/04 11:28:42 jilles Exp $
+
+$SH -nc 'echo bad'