aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-19 23:31:05 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-19 23:31:05 +0000
commitc12d51e94e219dfc212e7cdab64b314dbdb6e2f3 (patch)
treedae7ca4b3a095e7b3934057c15810481c8b9f81a
parent624188aec0e730375bb782a45ab3224b33dd30e9 (diff)
downloadbusybox-w32-c12d51e94e219dfc212e7cdab64b314dbdb6e2f3.tar.gz
busybox-w32-c12d51e94e219dfc212e7cdab64b314dbdb6e2f3.tar.bz2
busybox-w32-c12d51e94e219dfc212e7cdab64b314dbdb6e2f3.zip
ash: fix fallout from "A=1 B=$A; echo $B" code.
-rw-r--r--shell/ash.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 668953c0a..25c8fa521 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1785,22 +1785,26 @@ static struct globals_var *const ptr_to_globals_var __attribute__ ((section (".d
1785 } \ 1785 } \
1786} while (0) 1786} while (0)
1787 1787
1788#define vifs varinit[0] 1788#define vifs varinit[0]
1789#if ENABLE_ASH_MAIL 1789#if ENABLE_ASH_MAIL
1790#define vmail (&vifs)[1] 1790# define vmail (&vifs)[1]
1791#define vmpath (&vmail)[1] 1791# define vmpath (&vmail)[1]
1792# define vpath (&vmpath)[1]
1792#else 1793#else
1793#define vmpath vifs 1794# define vpath (&vifs)[1]
1794#endif 1795#endif
1795#define vpath (&vmpath)[1] 1796#define vps1 (&vpath)[1]
1796#define vps1 (&vpath)[1] 1797#define vps2 (&vps1)[1]
1797#define vps2 (&vps1)[1] 1798#define vps4 (&vps2)[1]
1798#define vps4 (&vps2)[1]
1799#define voptind (&vps4)[1]
1800#if ENABLE_ASH_GETOPTS 1799#if ENABLE_ASH_GETOPTS
1801#define vrandom (&voptind)[1] 1800# define voptind (&vps4)[1]
1801# if ENABLE_ASH_RANDOM_SUPPORT
1802# define vrandom (&voptind)[1]
1803# endif
1802#else 1804#else
1803#define vrandom (&vps4)[1] 1805# if ENABLE_ASH_RANDOM_SUPPORT
1806# define vrandom (&vps4)[1]
1807# endif
1804#endif 1808#endif
1805 1809
1806/* 1810/*
@@ -1810,15 +1814,18 @@ static struct globals_var *const ptr_to_globals_var __attribute__ ((section (".d
1810 */ 1814 */
1811#define ifsval() (vifs.text + 4) 1815#define ifsval() (vifs.text + 4)
1812#define ifsset() ((vifs.flags & VUNSET) == 0) 1816#define ifsset() ((vifs.flags & VUNSET) == 0)
1813#define mailval() (vmail.text + 5) 1817#if ENABLE_ASH_MAIL
1814#define mpathval() (vmpath.text + 9) 1818# define mailval() (vmail.text + 5)
1819# define mpathval() (vmpath.text + 9)
1820# define mpathset() ((vmpath.flags & VUNSET) == 0)
1821#endif
1815#define pathval() (vpath.text + 5) 1822#define pathval() (vpath.text + 5)
1816#define ps1val() (vps1.text + 4) 1823#define ps1val() (vps1.text + 4)
1817#define ps2val() (vps2.text + 4) 1824#define ps2val() (vps2.text + 4)
1818#define ps4val() (vps4.text + 4) 1825#define ps4val() (vps4.text + 4)
1819#define optindval() (voptind.text + 7) 1826#if ENABLE_ASH_GETOPTS
1820 1827# define optindval() (voptind.text + 7)
1821#define mpathset() ((vmpath.flags & VUNSET) == 0) 1828#endif
1822 1829
1823 1830
1824#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c))) 1831#define is_name(c) ((c) == '_' || isalpha((unsigned char)(c)))
@@ -5912,8 +5919,9 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
5912 unsigned name_len = (strchrnul(name, '=') - name) + 1; 5919 unsigned name_len = (strchrnul(name, '=') - name) + 1;
5913 p = NULL; 5920 p = NULL;
5914 do { 5921 do {
5915 char *str = var_str_list->text; 5922 char *str, *eq;
5916 char *eq = strchr(str, '='); 5923 str = var_str_list->text;
5924 eq = strchr(str, '=');
5917 if (!eq) /* stop at first non-assignment */ 5925 if (!eq) /* stop at first non-assignment */
5918 break; 5926 break;
5919 eq++; 5927 eq++;
@@ -7677,6 +7685,7 @@ evalfor(union node *n, int flags)
7677 struct stackmark smark; 7685 struct stackmark smark;
7678 7686
7679 setstackmark(&smark); 7687 setstackmark(&smark);
7688 arglist.list = NULL;
7680 arglist.lastp = &arglist.list; 7689 arglist.lastp = &arglist.list;
7681 for (argp = n->nfor.args; argp; argp = argp->narg.next) { 7690 for (argp = n->nfor.args; argp; argp = argp->narg.next) {
7682 expandarg(argp, &arglist, EXP_FULL | EXP_TILDE | EXP_RECORD); 7691 expandarg(argp, &arglist, EXP_FULL | EXP_TILDE | EXP_RECORD);
@@ -7716,6 +7725,7 @@ evalcase(union node *n, int flags)
7716 struct stackmark smark; 7725 struct stackmark smark;
7717 7726
7718 setstackmark(&smark); 7727 setstackmark(&smark);
7728 arglist.list = NULL;
7719 arglist.lastp = &arglist.list; 7729 arglist.lastp = &arglist.list;
7720 expandarg(n->ncase.expr, &arglist, EXP_TILDE); 7730 expandarg(n->ncase.expr, &arglist, EXP_TILDE);
7721 exitstatus = 0; 7731 exitstatus = 0;
@@ -7777,7 +7787,7 @@ expredir(union node *n)
7777 for (redir = n; redir; redir = redir->nfile.next) { 7787 for (redir = n; redir; redir = redir->nfile.next) {
7778 struct arglist fn; 7788 struct arglist fn;
7779 7789
7780 memset(&fn, 0, sizeof(fn)); 7790 fn.list = NULL;
7781 fn.lastp = &fn.list; 7791 fn.lastp = &fn.list;
7782 switch (redir->type) { 7792 switch (redir->type) {
7783 case NFROMTO: 7793 case NFROMTO: