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

Re: more splitting



On Wed, Apr 15, 2026 at 8:21 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> I hope my comments are correct:
>
>        read -d '' -r _hex_var   # -d:terminate on nul, -r:'raw'--all literal.

Correct.  The effect here is to read the entire input as one string.

>     # (q+):quote the quotes ... sorta, -C1: columns split on spaces.

Not exactly.  No splitting is done by "print".

When the name passed in refers to an array, ${(P)_hex_var} will also
be an array.  So:
  # (q+):quote the string, or quote each element if the value is an array
  # -C1: print each string or array element in a single column

Even more accurately:
 # (q+): apply quotes using the simpler of '...' or $'...' as needed
 # -C1: make one column out of all the arguments to "print".

You can also do -C2, etc.




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