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

Re: string to array space problem in filenames



On Wed, Sep 2, 2015 at 8:37 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:

> On 08/28/2015 12:43 PM, Bart Schaefer wrote:
>
> Bart,
>
> Got around to the spaces in filenames thing:
>
>>
>> If you insist on storing it all on one line, then you need to quote the
>> spaces on the way out:
>>
>>      echo -n " ${(q)PWD}" >>! ~/.mydirstack;
>>
>> I've got it all more or less working except I can't figure out how to
> write the array--with newlines now, not with spaces--back to the file.
> Everything I try ends up on one line, which is now not what I want anymore.
>

See the "F" flag in the "Parameter Expansion Flags" of the "man zshparam"
page:

Join  the  words of arrays together using newline as a separator.  This is
a shorthand for `pj:\n:'.


For example:

$ set -A x a b c
$ echo $x
a b c
$ echo ${(F)x}
a
b
c

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank


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