[BusyBox-cvs] svn commit: trunk/busybox/shell

pgf at busybox.net pgf at busybox.net
Wed Jul 20 18:23:41 UTC 2005


Author: pgf
Date: 2005-07-20 12:23:39 -0600 (Wed, 20 Jul 2005)
New Revision: 10875

Log:
applying fix from:
    0000152: ash: quoting rules for local variables different to globals  


Modified:
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2005-07-20 18:02:11 UTC (rev 10874)
+++ trunk/busybox/shell/ash.c	2005-07-20 18:23:39 UTC (rev 10875)
@@ -1353,6 +1353,7 @@
 
 #define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
 #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
+#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
 
 static const struct builtincmd builtincmd[] = {
 	{ BUILTIN_SPEC_REG      ".", dotcmd },
@@ -3208,8 +3209,15 @@
 }
 #endif
 
+static inline int
+isassignment(const char *p)
+{
+	const char *q = endofname(p);
+	if (p == q)
+		return 0;
+	return *q == '=';
+}
 
-
 /*
  * Execute a simple command.
  */
@@ -3232,6 +3240,8 @@
 	int cmd_is_exec;
 	int status;
 	char **nargv;
+	struct builtincmd *bcmd;
+	int pseudovarflag = 0;
 
 	/* First expand the arguments. */
 	TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@@ -3246,11 +3256,21 @@
 	*arglist.lastp = NULL;
 
 	argc = 0;
+	if (cmd->ncmd.args)
+	{
+		bcmd = find_builtin(cmd->ncmd.args->narg.text);
+		pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
+	}
+
 	for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
 		struct strlist **spp;
 
 		spp = arglist.lastp;
-		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+		if (pseudovarflag && isassignment(argp->narg.text)) 
+			expandarg(argp, &arglist, EXP_VARTILDE);
+		else
+			expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+
 		for (sp = *spp; sp; sp = sp->next)
 			argc++;
 	}
@@ -9356,16 +9376,7 @@
 
 
 
-static inline int
-isassignment(const char *p)
-{
-	const char *q = endofname(p);
-	if (p == q)
-		return 0;
-	return *q == '=';
-}
 
-
 /*
  * Read and parse a command.  Returns NEOF on end of file.  (NULL is a
  * valid parse tree indicating a blank line.)




More information about the busybox-cvs mailing list