Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Ternary expression in Zsh (was: Feature request – substitutions similar to +, -, :+, :-)
On 3 Dec 2017 at 10:11:10, Sebastian Gniazdowski (psprint@xxxxxxxxxxx) wrote:
> % var=abc
> % echo ${${${(M)var#abc(#e)}:+ternary1}:-ternary2}
> ternary1
> % var=abcd
> % echo ${${${(M)var#abc(#e)}:+ternary1}:-ternary2}
> ternary2
Upgrade that doesn't need extendedglob (#e needs it):
% var=abc
% echo ${${${(M)var:#abc}:+ternary1}:-ternary2}
ternary1
% var=abcd
% echo ${${${(M)var:#abc}:+ternary1}:-ternary2}
ternary2
Substituted :# for # and (#e). :# wants whole string, so no #e needed. Maybe this is what Bart was aiming at in previous topic.
--
Sebastian Gniazdowski
psprint /at/ zdharma.org
- References:
- Feature request – substitutions similar to +, -, :+, :-
- From: Sebastian Gniazdowski
- Re: Feature request – substitutions similar to +, -, :+, :-
- From: Sebastian Gniazdowski
- Re: Feature request – substitutions similar to +, -, :+, :-
- From: Sebastian Gniazdowski
- Ternary expression in Zsh (was: Feature request – substitutions similar to +, -, :+, :-)
- From: Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author