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

Re: Can I test if a parameter expansion has worked



On Wed, Sep 14, 2022 at 9:52 AM zzapper <zsh@xxxxxxxxxxxxxx> wrote:
>
> Q1) Can I test if a parameter expansion has 'fired'?

I'm not sure what that means.  Does 'fired' mean expanded to a
non-empty string, as in, the parameter has a value?  And, test when,
relative to the placement of the parameter reference?  And, what do
you want to do based on the result of the test?

The most obvious answer would be that ${param:?} will cause a fatal
error if the parameter is either unset or empty, but that doesn't
provide any avenue for recovery unless you use an "always" block
around it.




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