2025年8月29日(金) 20:16 Kevin Pulo <[email protected]>: > On Fri, 29 Aug 2025 at 01:00, Koichi Murase <[email protected]> wrote: > > If the feature is really desired by the community as an essential feature, > > it > > should be implemented as a new syntax. > > I looked at adding alternate syntax for doing command substitution without > stripping trailing newlines, and it turned out to be easier than I expected.
Thank you for preparing an alternative version for the newline-preserving comsub with a new syntax. I've checked the behavior of your patch and confirm that it works consistently as far as I've tried. I don't have a particular opinion about whether this should be merged, but I guess people in the old thread you mentioned [1] would be interested. [1] https://lists.gnu.org/archive/html/bug-bash/2021-01/msg00269.html > It's only necessary to do a nofork version, because if someone deliberately > wants to run inside a subshell (ie. fork instead of no-fork) then they can > just > do that explicitly with ${;(cmd;);}. Actually, you can simply write the above as ${; (cmd)}. I confirmed it with your patch. > I don't care much about the choice of character, ie. if something else would > be > better than ';'. A single character is definitely easier to parse and handle > than some of the fancier previous proposals, such as > https://lists.gnu.org/archive/html/bug-bash/2021-01/msg00269.html which is > very > extensible, but would be a lot more work. This part might want input from others. People may desire other types of variations in the command-substitution behavior, and we may want to consider how we should properly assign a syntax to each variation. For example, I actually have several variations for ``command-substitutions'' in my framework, but I implemented these as shell functions (which are similar to `grab_output' suggested in the original thread). I'm satisfied with the shell-function implementations, but people might like them implemented as shell-language features. One useful extension could be a variation of value substitutions that allows returning an array. For example, « x=("${@| REPLY=(1 2 3); }") » resulting in « x=(1 2 3) ». -- Koichi
