1 From https://ftp.gnu.org/gnu/bash/bash-4.4-patches/bash44-012
3 Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
11 Bug-Reported-by: Clark Wang <dearvoid@gmail.com>
12 Bug-Reference-ID: <CADv8-ojttPUFOZXqbjsvy83LfaJtQKZ5qejGdF6j0VJ3vtrYOA@mail.gmail.com>
13 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2016-11/msg00106.html
17 When -N is used, the input is not supposed to be split using $IFS, but
18 leading and trailing IFS whitespace was still removed.
20 Patch (apply with `patch -p0'):
22 *** bash-4.4-patched/subst.c 2017-01-20 14:22:01.000000000 -0500
23 --- b/subst.c 2017-01-25 13:43:22.000000000 -0500
26 /* Parse a single word from STRING, using SEPARATORS to separate fields.
27 ENDPTR is set to the first character after the word. This is used by
28 ! the `read' builtin. This is never called with SEPARATORS != $IFS;
29 ! it should be simplified.
31 XXX - this function is very similar to list_string; they should be
34 get_word_from_string (stringp, separators, endptr)
36 /* Parse a single word from STRING, using SEPARATORS to separate fields.
37 ENDPTR is set to the first character after the word. This is used by
40 ! This is never called with SEPARATORS != $IFS, and takes advantage of that.
42 XXX - this function is very similar to list_string; they should be
45 + #define islocalsep(c) (local_cmap[(unsigned char)(c)] != 0)
48 get_word_from_string (stringp, separators, endptr)
53 int sindex, sh_style_split, whitesep, xflags;
54 + unsigned char local_cmap[UCHAR_MAX+1]; /* really only need single-byte chars here */
59 separators[2] == '\n' &&
60 separators[3] == '\0';
61 ! for (xflags = 0, s = ifs_value; s && *s; s++)
63 if (*s == CTLESC) xflags |= SX_NOCTLESC;
64 if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
68 separators[2] == '\n' &&
69 separators[3] == '\0';
70 ! memset (local_cmap, '\0', sizeof (local_cmap));
71 ! for (xflags = 0, s = separators; s && *s; s++)
73 if (*s == CTLESC) xflags |= SX_NOCTLESC;
74 if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
75 + local_cmap[(unsigned char)*s] = 1; /* local charmap of separators */
81 /* Remove sequences of whitespace at the beginning of STRING, as
82 ! long as those characters appear in IFS. */
83 ! if (sh_style_split || !separators || !*separators)
85 ! for (; *s && spctabnl (*s) && isifs (*s); s++);
87 /* If the string is nothing but whitespace, update it and return. */
90 /* Remove sequences of whitespace at the beginning of STRING, as
91 ! long as those characters appear in SEPARATORS. This happens if
92 ! SEPARATORS == $' \t\n' or if IFS is unset. */
93 ! if (sh_style_split || separators == 0)
95 ! for (; *s && spctabnl (*s) && islocalsep (*s); s++);
97 /* If the string is nothing but whitespace, update it and return. */
100 This obeys the field splitting rules in Posix.2. */
102 ! /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
103 ! unless multibyte chars are possible. */
104 ! slen = (MB_CUR_MAX > 1) ? STRLEN (s) : 1;
105 current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
108 This obeys the field splitting rules in Posix.2. */
110 ! /* Don't need string length in ADVANCE_CHAR unless multibyte chars are
111 ! possible, but need it in string_extract_verbatim for bounds checking */
113 current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
117 /* Now skip sequences of space, tab, or newline characters if they are
118 in the list of separators. */
119 ! while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex]))
123 /* Now skip sequences of space, tab, or newline characters if they are
124 in the list of separators. */
125 ! while (s[sindex] && spctabnl (s[sindex]) && islocalsep (s[sindex]))
130 delimiter, not a separate delimiter that would result in an empty field.
131 Look at POSIX.2, 3.6.5, (3)(b). */
132 ! if (s[sindex] && whitesep && isifs (s[sindex]) && !spctabnl (s[sindex]))
135 /* An IFS character that is not IFS white space, along with any adjacent
136 IFS white space, shall delimit a field. */
137 ! while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex]))
141 delimiter, not a separate delimiter that would result in an empty field.
142 Look at POSIX.2, 3.6.5, (3)(b). */
143 ! if (s[sindex] && whitesep && islocalsep (s[sindex]) && !spctabnl (s[sindex]))
146 /* An IFS character that is not IFS white space, along with any adjacent
147 IFS white space, shall delimit a field. */
148 ! while (s[sindex] && spctabnl (s[sindex]) && islocalsep(s[sindex]))
151 *** bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
152 --- b/patchlevel.h 2016-10-01 11:01:28.000000000 -0400
155 looks for to find the patch level (for the sccs version string). */
157 ! #define PATCHLEVEL 11
159 #endif /* _PATCHLEVEL_H_ */
161 looks for to find the patch level (for the sccs version string). */
163 ! #define PATCHLEVEL 12
165 #endif /* _PATCHLEVEL_H_ */