Source-Changes-HG archive

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

[src/netbsd-3]: src/bin/sh Pull up revision 1.70 (requested by dsl in ticket ...



details:   https://anonhg.NetBSD.org/src/rev/2108ccc96f32
branches:  netbsd-3
changeset: 575286:2108ccc96f32
user:      tron <tron%NetBSD.org@localhost>
date:      Thu Apr 07 11:37:39 2005 +0000

description:
Pull up revision 1.70 (requested by dsl in ticket #119):
Check quoting before merging ifs regions.
sh -c 'set -- a; x="b c"; set -- "$@"$x'
now correctly gives $1=ab, $2=c

diffstat:

 bin/sh/expand.c |  25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diffs (60 lines):

diff -r a3ea97baa8a6 -r 2108ccc96f32 bin/sh/expand.c
--- a/bin/sh/expand.c   Thu Apr 07 11:36:28 2005 +0000
+++ b/bin/sh/expand.c   Thu Apr 07 11:37:39 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.68.2.1 2005/04/07 11:36:28 tron Exp $     */
+/*     $NetBSD: expand.c,v 1.68.2.2 2005/04/07 11:37:39 tron 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.68.2.1 2005/04/07 11:36:28 tron Exp $");
+__RCSID("$NetBSD: expand.c,v 1.68.2.2 2005/04/07 11:37:39 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -1009,8 +1009,8 @@
                        arglist->lastp = &sp->next;
                        p++;
 
-                       if (!inquotes) {
-                               /* Ignore trailing IFS whitespace */
+                       if (ifsspc != NULL) {
+                               /* Ignore further trailing IFS whitespace */
                                for (; p < string + ifsp->endoff; p++) {
                                        q = p;
                                        if (*p == CTLESC)
@@ -1020,11 +1020,8 @@
                                                break;
                                        }
                                        if (strchr(" \t\n", *p) == NULL) {
-                                               if (ifsspc == NULL) {
-                                                       p = q;
-                                                       break;
-                                               }
-                                               ifsspc = NULL;
+                                               p++;
+                                               break;
                                        }
                                }
                        }
@@ -1032,8 +1029,14 @@
                }
        }
 
-       /* Save anything left as an argument */
-       if (*start || (!ifsspc && start > string)) {
+       /*
+        * Save anything left as an argument.
+        * Traditionally we have treated 'IFS=':'; set -- x$IFS' as
+        * generating 2 arguments, the second of which is empty.
+        * Some recent clarification of the Posix spec say that it
+        * should only generate one....
+        */
+       if (*start /* || (!ifsspc && start > string) */) {
                sp = (struct strlist *)stalloc(sizeof *sp);
                sp->text = start;
                *arglist->lastp = sp;



Home | Main Index | Thread Index | Old Index