zsh-users
 help / color / mirror / code / Atom feed
* Number of non-empty elements
@ 2015-09-15 17:15 Jesper Nygårds
  2015-09-15 21:43 ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Nygårds @ 2015-09-15 17:15 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 554 bytes --]

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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-16  5:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-15 17:15 Number of non-empty elements Jesper Nygårds
2015-09-15 21:43 ` Daniel Shahaf
2015-09-16  5:16   ` Jesper Nygårds

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).