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

Re: Printing arrays for use with $()



On Aug 11,  6:16pm, DervishD wrote:
}
}     Is there any way for printing the array to stdout and being able
} to use that output as arguments for another command?

The short answer is, no.

The long answer is that *something* has to understand the format of the
printed output and convert it back into individual strings.  That means
that either

(1) you need a command that reads from standard input rather than taking
command line arguments, or

(2) you must be in control of the command line so that you can do the
appropriate parsing yourself.

For an example of (2), you could

    print -N -- $array

but then the caller must have IFS=$'\0' to split on the nuls without also
splitting on whitespace.



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