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

Number of non-empty elements



Here's a very little thing that's annoying me.

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.

This is the best I've come up with so far:

mylines=...

mylines=(${mylines}) # Remove empty elements
return $(( ${#mylines} == 0 ))

I particularly dislike that I have a separate line to remove empty lines.

Is there a more elegant, preferably one-line, solution to achieve this?


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