Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH?] Nofork and removing newlines



I don't know if that could be done and it's probably too late
anyway, but I thought I might throw in the idea anyway.

What about, instead of adding ksh93's ${ cmd;} and mksh's
${|cmd} (in slightly diverging ways), we added just a |
expansion flag whereby:

${(||)any zsh code} would expand to the output of the code
without the fork and without the newline trimming.

${(|var|)any zsh code} would expand to the value of var as set
by the zsh code

Some advantages:
- the flags can be cumulated as usual. So you can have ${(||.s[:])getconf PATH}
  to split the output of getconf PATH ("." to trim one newline,
  ".." to trim all) for example.
- there's no extra rule as to how the expansion works and how it
  can be combined with others as it's the same syntax as other
  parameter expansions
- as it's different syntax, it removes the potential surprises
  when ${ cmd;}, ${|cmd} behave differently than in
  ksh93/mksh/bash

=============

Or (as a completely different idea), an alternative to
mksh's ${|cmd} and ${|var|cmd} could be written ${REPLY<cmd}
${var<cmd}.

That could be added as well as ${|cmd} if we wanted to add
${|cmd} for compatibility with mksh/bash.

Or we could add neither of ${ cmd;} and ${|cmd} and have
${REPLY<cmd} as the (non-splitting, non-trimming) equivalent of
${|cmd} and ${<cmd} as the (non-splitting, non-trimming)
equivalent of ${ cmd;} (though the latter would prevent adding
${ cmd; } in the future).

And still allow flags there as in ${(.s[:])<getconf PATH}

-- 
Stephane
- 




Messages sorted by: Reverse Date, Date, Thread, Author