You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.4 KiB

  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 4.3
  4. Patch-ID: bash43-014
  5. Bug-Reported-by: Greg Wooledge <wooledg@eeg.ccf.org>
  6. Bug-Reference-ID: <20140418202123.GB7660@eeg.ccf.org>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/help-bash/2014-04/msg00004.html
  8. Bug-Description:
  9. Under certain circumstances, $@ is expanded incorrectly in contexts where
  10. word splitting is not performed.
  11. Patch (apply with `patch -p0'):
  12. --- a/subst.c
  13. +++ b/subst.c
  14. @@ -3248,8 +3248,10 @@ cond_expand_word (w, special)
  15. if (w->word == 0 || w->word[0] == '\0')
  16. return ((char *)NULL);
  17. + expand_no_split_dollar_star = 1;
  18. w->flags |= W_NOSPLIT2;
  19. l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0);
  20. + expand_no_split_dollar_star = 0;
  21. if (l)
  22. {
  23. if (special == 0) /* LHS */
  24. @@ -7847,6 +7849,10 @@ param_expand (string, sindex, quoted, ex
  25. We also want to make sure that splitting is done no matter what --
  26. according to POSIX.2, this expands to a list of the positional
  27. parameters no matter what IFS is set to. */
  28. + /* XXX - what to do when in a context where word splitting is not
  29. + performed? Even when IFS is not the default, posix seems to imply
  30. + that we behave like unquoted $* ? Maybe we should use PF_NOSPLIT2
  31. + here. */
  32. temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted);
  33. tflag |= W_DOLLARAT;
  34. @@ -8816,6 +8822,7 @@ finished_with_string:
  35. else
  36. {
  37. char *ifs_chars;
  38. + char *tstring;
  39. ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
  40. @@ -8830,11 +8837,36 @@ finished_with_string:
  41. regardless of what else has happened to IFS since the expansion. */
  42. if (split_on_spaces)
  43. list = list_string (istring, " ", 1); /* XXX quoted == 1? */
  44. + /* If we have $@ (has_dollar_at != 0) and we are in a context where we
  45. + don't want to split the result (W_NOSPLIT2), and we are not quoted,
  46. + we have already separated the arguments with the first character of
  47. + $IFS. In this case, we want to return a list with a single word
  48. + with the separator possibly replaced with a space (it's what other
  49. + shells seem to do).
  50. + quoted_dollar_at is internal to this function and is set if we are
  51. + passed an argument that is unquoted (quoted == 0) but we encounter a
  52. + double-quoted $@ while expanding it. */
  53. + else if (has_dollar_at && quoted_dollar_at == 0 && ifs_chars && quoted == 0 && (word->flags & W_NOSPLIT2))
  54. + {
  55. + /* Only split and rejoin if we have to */
  56. + if (*ifs_chars && *ifs_chars != ' ')
  57. + {
  58. + list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
  59. + tstring = string_list (list);
  60. + }
  61. + else
  62. + tstring = istring;
  63. + tword = make_bare_word (tstring);
  64. + if (tstring != istring)
  65. + free (tstring);
  66. + goto set_word_flags;
  67. + }
  68. else if (has_dollar_at && ifs_chars)
  69. list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
  70. else
  71. {
  72. tword = make_bare_word (istring);
  73. +set_word_flags:
  74. if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
  75. tword->flags |= W_QUOTED;
  76. if (word->flags & W_ASSIGNMENT)
  77. --- a/patchlevel.h
  78. +++ b/patchlevel.h
  79. @@ -25,6 +25,6 @@
  80. regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
  81. looks for to find the patch level (for the sccs version string). */
  82. -#define PATCHLEVEL 13
  83. +#define PATCHLEVEL 14
  84. #endif /* _PATCHLEVEL_H_ */