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

Re: Feature request: a new warning option



2019-10-09 15:41:41 +0200, Sebastian Gniazdowski:
[...]
> I thought that:
> 
> [[ -z $ver ]] && ver="unknown (no .git/refs/heads/master)" || ver=${ver[1,7]}
> 
> is more or equally readable to:
> 
> if [[ -z $ver ]]; then
>     ver="unknown (no .git/refs/heads/master)"
> else
>     ver=${ver[1,7]}
> fi
[...]

but thyes are different things.

a && b || c, is "run c unles both a and b succeed".

You typically use these things in if statements like

if a && b || c; then
  ...
fi


You could always do something like:

alias -g '^=else'
if ((x)){echo yes} ^ {echo no}

(can be shortened to if((x)){echo yes} ^ {echo no} with zsh -o
noglobqual -o shglob).

Or even:

alias -g '&|=else'
alias '?=if'
? ((x)){echo yes}&|{echo no}

-- 
Stephane



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