7 Bug-Reported-by: Greg Wooledge <wooledg@eeg.ccf.org>
8 Bug-Reference-ID: <20140418202123.GB7660@eeg.ccf.org>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/help-bash/2014-04/msg00004.html
13 Under certain circumstances, $@ is expanded incorrectly in contexts where
14 word splitting is not performed.
16 Patch (apply with `patch -p0'):
17 *** ../bash-4.3-patched/subst.c 2014-01-23 16:26:37.000000000 -0500
18 --- subst.c 2014-04-19 15:41:26.000000000 -0400
22 return ((char *)NULL);
24 + expand_no_split_dollar_star = 1;
25 w->flags |= W_NOSPLIT2;
26 l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0);
27 + expand_no_split_dollar_star = 0;
33 according to POSIX.2, this expands to a list of the positional
34 parameters no matter what IFS is set to. */
35 + /* XXX - what to do when in a context where word splitting is not
36 + performed? Even when IFS is not the default, posix seems to imply
37 + that we behave like unquoted $* ? Maybe we should use PF_NOSPLIT2
39 temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted);
48 ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
53 list = list_string (istring, " ", 1); /* XXX quoted == 1? */
54 + /* If we have $@ (has_dollar_at != 0) and we are in a context where we
55 + don't want to split the result (W_NOSPLIT2), and we are not quoted,
56 + we have already separated the arguments with the first character of
57 + $IFS. In this case, we want to return a list with a single word
58 + with the separator possibly replaced with a space (it's what other
60 + quoted_dollar_at is internal to this function and is set if we are
61 + passed an argument that is unquoted (quoted == 0) but we encounter a
62 + double-quoted $@ while expanding it. */
63 + else if (has_dollar_at && quoted_dollar_at == 0 && ifs_chars && quoted == 0 && (word->flags & W_NOSPLIT2))
65 + /* Only split and rejoin if we have to */
66 + if (*ifs_chars && *ifs_chars != ' ')
68 + list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
69 + tstring = string_list (list);
73 + tword = make_bare_word (tstring);
74 + if (tstring != istring)
76 + goto set_word_flags;
78 else if (has_dollar_at && ifs_chars)
79 list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
84 tword = make_bare_word (istring);
86 if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
87 tword->flags |= W_QUOTED;
88 *** ../bash-4.3/patchlevel.h 2012-12-29 10:47:57.000000000 -0500
89 --- patchlevel.h 2014-03-20 20:01:28.000000000 -0400
92 looks for to find the patch level (for the sccs version string). */
94 ! #define PATCHLEVEL 13
96 #endif /* _PATCHLEVEL_H_ */
98 looks for to find the patch level (for the sccs version string). */
100 ! #define PATCHLEVEL 14
102 #endif /* _PATCHLEVEL_H_ */