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

Re: Number of non-empty elements



Jesper Nygårds wrote on Tue, Sep 15, 2015 at 19:15:01 +0200:
> I have a fairly long function where the result is stored in an array called
> "mylines".
> 
> I want the function to return normally (status zero) if "mylines" contains
> at least one non-empty element, and with non-zero otherwise.

    return $(( $mylines[(I)?*] > 0 )0

The (I) modifier interprets the key as a pattern and returns the highest
index of a match, or 0 if there was no match.



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