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

Re: PATCH: expanding parameters like echo/print builtins



On May 14,  1:41pm, Jilles Tjoelker wrote:
} Subject: Re: PATCH: expanding parameters like echo/print builtins
}
} > [${(g)parameter} expansion for expanding like echo/print]
} 
} Am I really strange in thinking this should really be done using command
} substitution of echo, print or printf with appropriate options?

A lot of features added to zsh are things that could be done another
way but that it's more convenient to have a shortcut.

E.g., one could argue that $((5 + 3)) should really be done using
$(expr 5 + 3), etc.

} Admittedly, this requires precautions if trailing newlines are
} significant [...]
} Other tricks are using eval with $'...' (requires special care for '
} and is not in POSIX.1-2008).

It's often precisely to avoid those precautions and "special care"
cases that things like (g) get introduced.
 
} In general, I think the ${(foo)parameter} forms are mostly write-only
} code for interactive use, except perhaps if you use them a lot.

I think you've got that exactly backward. :-)  If these forms were
primarily for interactive use, the syntax would probably be a lot
less convoluted.  $'...' is for interactive use.  ${(g:oe:)...}, not
so much.



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