Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Feature request – substitutions similar to +, -, :+, :-
- X-seq: zsh-workers 42032
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Sebastian Gniazdowski <psprint@xxxxxxxxxxx>
- Subject: Re: Feature request – substitutions similar to +, -, :+, :-
- Date: Sat, 18 Nov 2017 10:46:18 -0800
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=H4bol7YAJdGwMqLSqq5YZXl6wUL3GhM1vx9odapt2xs=; b=zm5yzsr65ubuFjxpoaLYfYxNfnlFRNIzLIIKF+uKx14TvOl0YaUaBz9mTTR48EOqGu 0uaW16ESIHv/2jEYxG1wgNbjjahq9yWHvStANrVMQFxsjurnbYGaHD30vFnnDjWgPt27 EK4rGsT5ij9VE7mD9nHMzd4IuRyaQi4UEwRhqIePV+BRJOq4l7i40MJGnQWvgiVou7jm XdwMe8WZOyIrFhIKHWC0rZbdRM+Qj+/Wqk3QxNzKa3rzhV9CCCjNYJM9JbEzokeeJQ6f FGztQCu9iYtn9XV6i3gHlmUa0X1dqq30jVbq8vkk+yZpsbqn6voeHMv658WGAzbJICGu jkUw==
- In-reply-to: <etPan.5a107a4b.459f7f60.137@zdharma.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <etPan.5a107666.74b42c6c.137@zdharma.org> <etPan.5a107a4b.459f7f60.137@zdharma.org>
On Sat, Nov 18, 2017 at 10:22 AM, Sebastian Gniazdowski
<psprint@xxxxxxxxxxx> wrote:
>
> On 18 Nov 2017 at 19:05:25, Sebastian Gniazdowski (psprint@xxxxxxxxxxx) wrote:
> > echo "I'm ${${theme[use-name]:&Patrick}:-a subscriber}, hello."
>
> Just realized that with the description of :& I gave, this would work the same, except not only for "1", but any non-empty string:
>
> echo "I'm ${${theme[use-name]:+Patrick}:-a subscriber}
>
> So it's a matter of getting consensus on details of :& and :^.
If I understand your example correctly, $theme[use-name] is either
unset/empty, or it contains "1" or "0".
So I think :& is just ${(M)theme[use-name]:#1} and :^ is ${theme[use-name]:#0}.
For $options, ${(M)options[...]:#on} and ${options[...]:#off}, so this
trick works with non-numeric booleans too.
You can do something similar with ${var/pat/repl} if you need to test
for substrings.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author