Module Name:    src
Committed By:   christos
Date:           Tue Mar  8 14:09:07 UTC 2016

Modified Files:
        src/bin/sh: expand.c

Log Message:
PR bin/50834o: fix expansions of (unquoted) ${unset_var-} and ""$@ (from kre)


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/bin/sh/expand.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/expand.c
diff -u src/bin/sh/expand.c:1.95 src/bin/sh/expand.c:1.96
--- src/bin/sh/expand.c:1.95	Sat Feb 27 11:28:50 2016
+++ src/bin/sh/expand.c	Tue Mar  8 09:09:07 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: expand.c,v 1.95 2016/02/27 16:28:50 christos Exp $	*/
+/*	$NetBSD: expand.c,v 1.96 2016/03/08 14:09:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c	8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.95 2016/02/27 16:28:50 christos Exp $");
+__RCSID("$NetBSD: expand.c,v 1.96 2016/03/08 14:09:07 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -204,7 +204,8 @@ argstr(char *p, int flag)
 			return;
 		case CTLQUOTEMARK:
 			/* "$@" syntax adherence hack */
-			if (p[0] == CTLVAR && p[2] == '@' && p[3] == '=')
+			if (p[0] == CTLVAR && p[1] & VSQUOTE &&
+			    p[2] == '@' && p[3] == '=')
 				break;
 			if ((flag & EXP_FULL) != 0)
 				STPUTC(c, expdest);
@@ -330,7 +331,7 @@ removerecordregions(int endoff)
 		}
 		return;
 	}
-	
+
 	ifslastp = &ifsfirst;
 	while (ifslastp->next && ifslastp->next->begoff < endoff)
 		ifslastp=ifslastp->next;
@@ -745,8 +746,9 @@ again: /* jump here after setting a vari
 			 * 'apply_ifs = 0' apparently breaks ${1+"$@"}..
 			 * ${x-'a b' c} should generate 2 args.
 			 */
+			if (*p != CTLENDVAR)
 			/* We should have marked stuff already */
-			apply_ifs = 0;
+				apply_ifs = 0;
 		}
 		break;
 

Reply via email to