Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: expanding parameters like echo/print builtins
- X-seq: zsh-workers 29228
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: PATCH: expanding parameters like echo/print builtins
- Date: Wed, 11 May 2011 18:22:03 +0200
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=B34kBudJjTa0ekPVT58DkjhOd9EGzdExGBgLP1n2ESc=; b=d4u4LGEfZbY0ENZ7d0NN9hNwB64yPreO05aaKkmPha/IoEvmNSUfmR2tCOTixypWhP eO4amKIq8H1K2yLs3U2x21kjENoNoNxTpBm548btMLU/w2jBv1lXfJgZZ5//COz135t/ /350+Ugi37v33ac9qLpQ2dnvurcZwCvg1Pu1c=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=KjfiwZgHy5KLj5qG0D5sRfjRn1t8p8ndaYBJ/rWXJi2mxjw80ogHQ4jXqmE3vtd6P+ 1iElfScfzv1U30nePisDf6RJwVbJeZGn7MGX7aG7oi0XMr+KiqmffldVuwf1AIHY8D+J sNFAbbPtHV3Nr5Uf/WsHnn68vSeGMe9dJrW14=
- In-reply-to: <110511090302.ZM23917@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1305118971-25617-1-git-send-email-mikachu@gmail.com> <110511080327.ZM23776@torch.brasslantern.com> <BANLkTikEes0aKU-GYW3Q7Xd_aQteHWdvQw@mail.gmail.com> <110511090302.ZM23917@torch.brasslantern.com>
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