bash52-003.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 5.2
  4. Patch-ID: bash52-003
  5. Bug-Reported-by: D630 <d630@posteo.net>
  6. Bug-Reference-ID: <cf8523d58ac75b9ffba9519faa175618@posteo.de>
  7. Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00092.html
  8. Bug-Description:
  9. Command substitutions need to preserve newlines instead of replacing them
  10. with semicolons, especially in the presence of multiple here-documents.
  11. Patch (apply with `patch -p0'):
  12. *** ../bash-5.2-patched/print_cmd.c 2022-07-26 09:16:39.000000000 -0400
  13. --- print_cmd.c 2022-10-17 10:41:06.000000000 -0400
  14. ***************
  15. *** 298,305 ****
  16. --- 298,307 ----
  17. {
  18. char c = command->value.Connection->connector;
  19. + int was_newline;
  20. s[0] = printing_comsub ? c : ';';
  21. s[1] = '\0';
  22. + was_newline = deferred_heredocs == 0 && was_heredoc == 0 && c == '\n';
  23. if (deferred_heredocs == 0)
  24. {
  25. ***************
  26. *** 315,318 ****
  27. --- 317,322 ----
  28. if (inside_function_def)
  29. cprintf ("\n");
  30. + else if (printing_comsub && c == '\n' && was_newline == 0)
  31. + cprintf ("\n"); /* preserve newlines in comsubs but don't double them */
  32. else
  33. {
  34. ***************
  35. *** 1366,1370 ****
  36. }
  37. else
  38. ! newline ("}");
  39. dispose_command (cmdcopy);
  40. --- 1371,1379 ----
  41. }
  42. else
  43. ! {
  44. ! /* { */
  45. ! newline ("}");
  46. ! was_heredoc = 0; /* not printing any here-documents now */
  47. ! }
  48. dispose_command (cmdcopy);
  49. ***************
  50. *** 1443,1447 ****
  51. }
  52. else
  53. ! newline ("}");
  54. result = the_printed_command;
  55. --- 1452,1459 ----
  56. }
  57. else
  58. ! { /* { */
  59. ! newline ("}");
  60. ! was_heredoc = 0;
  61. ! }
  62. result = the_printed_command;
  63. *** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
  64. --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
  65. ***************
  66. *** 26,30 ****
  67. looks for to find the patch level (for the sccs version string). */
  68. ! #define PATCHLEVEL 2
  69. #endif /* _PATCHLEVEL_H_ */
  70. --- 26,30 ----
  71. looks for to find the patch level (for the sccs version string). */
  72. ! #define PATCHLEVEL 3
  73. #endif /* _PATCHLEVEL_H_ */