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

better grammar with $#




    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.



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