]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/patches/bash/bash51-004
Merge branch 'master' of ssh://git.ipfire.org/pub/git/ipfire-2.x
[people/mfischer/ipfire-2.x.git] / src / patches / bash / bash51-004
1 BASH PATCH REPORT
2 =================
3
4 Bash-Release: 5.1
5 Patch-ID: bash51-004
6
7 Bug-Reported-by: oguzismailuysal@gmail.com
8 Bug-Reference-ID: <CAH7i3LoHGmwaghDpCWRUfcY04gQmeDTH3RiG=bf2b=KbU=gyhw@mail.gmail.com>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2020-12/msg00039.html
10
11 Bug-Description:
12
13 If a key-value compound array assignment to an associative array is supplied
14 as an assignment statement argument to the `declare' command that declares the
15 array, the assignment doesn't perform the correct word expansions.
16
17 This patch makes key-value assignment and subscript assignment perform the
18 same expansions when they're supplied as an argument to `declare'.
19
20 Patch (apply with `patch -p0'):
21
22 *** ../bash-5.1-patched/arrayfunc.c 2020-10-09 11:38:58.000000000 -0400
23 --- arrayfunc.c 2020-12-11 15:12:22.000000000 -0500
24 ***************
25 *** 598,601 ****
26 --- 598,622 ----
27 }
28 }
29 +
30 + /* Return non-zero if L appears to be a key-value pair associative array
31 + compound assignment. */
32 + int
33 + kvpair_assignment_p (l)
34 + WORD_LIST *l;
35 + {
36 + return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '['); /*]*/
37 + }
38 +
39 + char *
40 + expand_and_quote_kvpair_word (w)
41 + char *w;
42 + {
43 + char *t, *r;
44 +
45 + t = w ? expand_assignment_string_to_string (w, 0) : 0;
46 + r = sh_single_quote (t ? t : "");
47 + free (t);
48 + return r;
49 + }
50 #endif
51
52 ***************
53 *** 641,645 ****
54
55 #if ASSOC_KVPAIR_ASSIGNMENT
56 ! if (assoc_p (var) && nlist && (nlist->word->flags & W_ASSIGNMENT) == 0 && nlist->word->word[0] != '[') /*]*/
57 {
58 iflags = flags & ~ASS_APPEND;
59 --- 662,666 ----
60
61 #if ASSOC_KVPAIR_ASSIGNMENT
62 ! if (assoc_p (var) && kvpair_assignment_p (nlist))
63 {
64 iflags = flags & ~ASS_APPEND;
65 *** ../bash-5.1-patched/arrayfunc.h 2020-04-29 17:24:15.000000000 -0400
66 --- arrayfunc.h 2020-12-11 14:23:50.000000000 -0500
67 ***************
68 *** 68,71 ****
69 --- 68,74 ----
70 extern void quote_compound_array_list PARAMS((WORD_LIST *, int));
71
72 + extern int kvpair_assignment_p PARAMS((WORD_LIST *));
73 + extern char *expand_and_quote_kvpair_word PARAMS((char *));
74 +
75 extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int));
76 extern int skipsubscript PARAMS((const char *, int, int));
77 *** ../bash-5.1-patched/subst.c 2020-11-16 10:33:15.000000000 -0500
78 --- subst.c 2020-12-11 15:11:10.000000000 -0500
79 ***************
80 *** 11605,11608 ****
81 --- 11605,11609 ----
82 WORD_LIST *l, *nl;
83 char *t;
84 + int kvpair;
85
86 if (flags == 0)
87 ***************
88 *** 11619,11622 ****
89 --- 11620,11627 ----
90 /* Associative array */
91 l = parse_string_to_word_list (value, 1, "array assign");
92 + #if ASSOC_KVPAIR_ASSIGNMENT
93 + kvpair = kvpair_assignment_p (l);
94 + #endif
95 +
96 /* For associative arrays, with their arbitrary subscripts, we have to
97 expand and quote in one step so we don't have to search for the
98 ***************
99 *** 11624,11627 ****
100 --- 11629,11638 ----
101 for (nl = l; nl; nl = nl->next)
102 {
103 + #if ASSOC_KVPAIR_ASSIGNMENT
104 + if (kvpair)
105 + /* keys and values undergo the same set of expansions */
106 + t = expand_and_quote_kvpair_word (nl->word->word);
107 + else
108 + #endif
109 if ((nl->word->flags & W_ASSIGNMENT) == 0)
110 t = sh_single_quote (nl->word->word ? nl->word->word : "");
111
112 *** ../bash-5.1/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
113 --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
114 ***************
115 *** 26,30 ****
116 looks for to find the patch level (for the sccs version string). */
117
118 ! #define PATCHLEVEL 3
119
120 #endif /* _PATCHLEVEL_H_ */
121 --- 26,30 ----
122 looks for to find the patch level (for the sccs version string). */
123
124 ! #define PATCHLEVEL 4
125
126 #endif /* _PATCHLEVEL_H_ */