Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh PR bin/50834o: fix expansions of (unquoted) ${unset_v...



details:   https://anonhg.NetBSD.org/src/rev/dc6c683f0c20
branches:  trunk
changeset: 343986:dc6c683f0c20
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 08 14:09:07 2016 +0000

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

diffstat:

 bin/sh/expand.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (48 lines):

diff -r 1f3731faa6e1 -r dc6c683f0c20 bin/sh/expand.c
--- a/bin/sh/expand.c   Tue Mar 08 14:08:39 2016 +0000
+++ b/bin/sh/expand.c   Tue Mar 08 14:09:07 2016 +0000
@@ -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 @@
                        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 @@
                }
                return;
        }
-       
+
        ifslastp = &ifsfirst;
        while (ifslastp->next && ifslastp->next->begoff < endoff)
                ifslastp=ifslastp->next;
@@ -745,8 +746,9 @@
                         * '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;
 



Home | Main Index | Thread Index | Old Index