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

Re: Can I test if a parameter expansion has worked



On Thu, Sep 15, 2022 at 12:34 AM zzapper <zsh@xxxxxxxxxxxxxx> wrote:
>
> print ${f/%(#m).[pjg][npi]e#[gf]/_s$MATCH}
> stuff.txt  #  expansion has obviously left the input unchanged but can I
> test for that???

In the general case, no, as PWS has already addressed.

In this specific case, tho, if you "unset MATCH" before doing the
substitution, you can test $+MATCH after.




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