zsh-users
 help / color / mirror / code / Atom feed
* better grammar with $#
@ 2022-10-30 14:16 Ray Andrews
  2022-10-30 17:21 ` Philippe Troin
  2022-10-30 17:29 ` Roman Perepelitsa
  0 siblings, 2 replies; 4+ messages in thread
From: Ray Andrews @ 2022-10-30 14:16 UTC (permalink / raw)
  To: Zsh Users

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


     output=$( eval "$@" )  # Input here is a 'find' command outputting 
a list of files.
     tmp=( ${(f)output} )   # Count lines not characters.
     linecount=$#tmp

... it seems clumsy to create 'tmp' just to count lines, can that be a 
bit more streamlined?  And is it lines or words there?  The output is 
filenames so words=lines in this case but maybe not in other cases so 
I'd like to be sure to have a count of lines.  Easy to get one's 
splitting wrong.


BTW the ultimate in minutiae but the manual says:

12 Conditional Expressions

A /conditional expression/ is used with the [[ compound command to test 
attributes of files and to compare strings. Each expression can be 
constructed from one or more of the following unary or binary expressions:

... and AFAICT the tests work fine with the single '[' as well.

[-- Attachment #2: Type: text/html, Size: 1165 bytes --]

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

end of thread, other threads:[~2022-10-30 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-30 14:16 better grammar with $# Ray Andrews
2022-10-30 17:21 ` Philippe Troin
2022-10-30 17:29 ` Roman Perepelitsa
2022-10-30 17:49   ` Ray Andrews

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).