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

Parameter expansion flags question



Title: Parameter expansion flags question

Ive been writing a function to run a command, extract the first word of each line of the commands output and use that as a parameter to another command. The commands output looks like this:

After some trial-and-error I finally have the following function:

Im new to the zsh parameter expansion flags, but Ive gathered the ${(f) will take the commands output a line at a time, and the ${=site} will then split each line into words, allowing me to grab the first word of each line.

Is there a better (or simpler!) way to do this?  When the command has no output, the `for loop is still executed once (seemingly because the command is within double-quotes) and is the reason for checking that the length of $sitepath is non-zero. Is there a way to avoid the loop being entered when the command has no output and avoid the need for this check?

(btw, is there a good set of examples of using parameter expansion flags? The zsh guide seemed a bit sparse in this area)

Thanks,

    --- John



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