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

Re: PATCH: expanding parameters like echo/print builtins



On 11 May 2011 18:03, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On May 11,  5:14pm, Mikael Magnusson wrote:
> } Subject: Re: PATCH: expanding parameters like echo/print builtins
> }
> } On 11 May 2011 17:03, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> } >
> } > I'd probably have done it with ${(%)arr:gs/%/%%}
> }
> } Yeah, me too, except (%) doesn't expand \u304c or \0123, or any of the
> } other stuff that (g) expands :).
>
> Hrm.  What was I thinking of?  Obviously hadn't eaten breakfast yet.
>
> } I looked at the list of letters and the first free one was b, so i
> } picked that, then when i got as far as discover that the function is
> } called getkeystring and noticed g was also free, i went with that.
> } [...] The following characters are taken:
> } #%@AacCDefFikLnoOPqQtuUvVwWXz0p~jlmrsZ_lBEMNR
>
> So ...
>
> x='#%@AacCDefFikLnoOPqQtuUvVwWXz0p~jlmrsZ_lBEMNR'
> y=( {$[##a]..$[##z]} {$[##A]..$[##Z]} )
> print ${${(#)y}:#[$x]}
>
> b d g h x y G H I J K S T Y
>
> I guess (g) is as good as anything, unless someone prefers to save the
> lowercase letters and go with (G).

Oops, I typed l twice, the second one was supposed to be I, so the list is
b d g h x y G H J K S T Y

Do I need to clarify in the docs that you write g:: to give neither of
the three flags? Just g by itself is an error, like for the other
flags that take options. There's not really any good reason for this
other than it is much easier to reuse the code used by s and j (and
Z). But for s/j you want to be able to specify any character, whereas
for this flag there are a limited number of options, so : could be
obligatory for the field separator, then you could say just (g). Does
anyone care about this? :) (It would also mean we can't use : as a new
flag though).

-- 
Mikael Magnusson



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