Zsh Mailing List Archive
Messages sorted by:
Re: Feature request: a new warning option
- X-seq: zsh-users 24330
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: Feature request: a new warning option
- Date: Wed, 9 Oct 2019 13:56:28 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uFKLmNDutzDXb8aUGCN9oddHKoIr/LN9P7JldXLxSeY=; b=OZbUp1eswt1hr65cL62x++WGJbqsVoCfnWzX6UjJZu8Us7BkaE4uTs5EMzgGdD5W4g 1cXuzOvQVnPkEJPRye8tjjKuNyYwUsSCpOxL8tzh7vH9Dbe7p+qIdjscfj3RBumMfAgy lgIMxdqtkSoNsG2WbDZdbZvWKXVMoMwHluwpdyz9tVa/u5ae05w3wW+JMJasrZ5GFRnO 7CxJs1/y5DgKC07eVTV/tlFVOiPwPJhst8o8fM+aXZrwvsnVx676zabFNRX1Hqb6U84R hUHkXfZOa9htr3Rc0Jzc8uR4Q/suH6mu+WDX9wcvMJcllgoxd2k4dFSobo9t/vuguAAN xqHw==
- In-reply-to: <CAN=4vMraXtTooeYfBDGObA7xVhoC6JpHRz1C3CUHKiW=LY8Nuw@mail.gmail.com>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- List-unsubscribe: <mailto:email@example.com>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVDN-GspoiS-iVR5ThdbDVbLWVNJWcZ=TyY0=9ydtPswAw@mail.gmail.com> <CAN=4vMraXtTooeYfBDGObA7xVhoC6JpHRz1C3CUHKiW=LY8Nuw@mail.gmail.com>
On Wed, 9 Oct 2019 at 10:45, Roman Perepelitsa
> I myself am guilty of using `x && y || z` in place of a ternary
> and this leads to bugs that your proposed warning is meant to flag.
> However, if I were to enable this warning, I wouldn't be able to
> use `x && y || z` when it is the best tool for the job. Hence I'm
> leaning towards unlearning my current habbit and starting to use
> `if-else` more.
> What do you think?
I like the ternary-use of &&/||. I format the code as follows:
(( condition )) && \
code || \
I even use the ((1)) addition to the code || often. However, I might
get onto the alternate syntax-way you've proposed, it looks nice.
As for the non-ternary, i.e. symmetric-and-still-correct use of &&/||
I would say: the code that is needy of using &&/|| in such a way can
skip this hypothetical new warning option. Covering 8 out of 10
functions with it is still a good result (this reminds me the previous
discussion we've had).
I in general am a very happy user of warn_create_global and I see how
much warning-options can give, hence the feature request. I however
don't use warn_nested_var, I'm now starting to wonder why, as even
that I've sometimes write code using variables from upper scope, the
"covering 8 out ouf 10 functions..." point would apply here too. It's
however a recent option, not forever-present like the
warn_create_global. I wonder if a very much compressed way of enabling
warn_nested_var only on shells that have it exists.
Messages sorted by: