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

Re: [PATCH?] Nofork and removing newlines



On Fri, Mar 8, 2024 at 2:15 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> Why does it print command not found errors for things like ${|=|:},
> ${|*|:} and ${|?|:}, I'd rather have $? than it globbing for a single

Bart Schaefer wrote:
> See above about the requirement for it to look like ${|ident|...}.
> Since = * and ? are not identifiers, this is like writing { =|: } etc.> character file.

On Sat, Mar 9, 2024 at 12:44 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> You may not be able to assign to it directly but I can think of uses
> for $? (and perhaps also $!) if supported there.

On Sat, Mar 9, 2024 at 10:11 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> $? is also $status and ${|status|...} is fine.
>
> Pondering $! ... hm.

This can be done with e.g.

typeset -n bang=!
... ${|bang|...} ...

And that doesn't even run afoul of history expansion, though I would
not expect $! to be used that much in an interactive context.

However:

Returning to the original context here, we were talking about how to
make ${ ... } more newline-trimming-compatible with $(...) while still
providing a way to specify that newlines not be trimmed, and using
${||...} for the latter came up.

In thinking about ${|?|...} etc. I realized that there's no real
reason a set of non-identifier characters couldn't be allowed to
follow the first vertical bar.  It'd have to be simpler than just
tossing parameter expansion flags in there, but I could investigate
whether we could do things like ${|=|...} is the same as ${=${ ... }},
${|~|...} is ${~${ ... }}, etc.  That only saves 1 character, though,
and I'm not sure it's clearer.

It does mean, though, that we could use something like ${|<|...} for
non-trimming command substitution, instead of "empty" || meaning that.
Just from a "clean look" standpoint, though, I still like the quoting
approach better.

Separately, it's definitely possible to make zsh-mode ${ ... } trim
only one newline instead of all of them.




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