Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Feature request: a new warning option
- X-seq: zsh-users 24327
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Feature request: a new warning option
- Date: Wed, 9 Oct 2019 06:02:26 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=TQl4hVWIP8csYS9o0mTzkBaf96OqJvUm1GwXQz0ilm4=; b=qE1kftcShQUJlkjrE/ZUckwlrTM5dKl4mgHX8JuPCX4b0PJgYcewsTzH5LZ/o0HpnI v0rHNaojcJaGOk3fAIXGpAIYhEFFaH2XHxjQ3Q1RLr+32UJa5HaF1MO4FsfLZzlE2YUP lYZtIsC181d9bZIjJdl2tovEczU1POhO/L3LoBPToyyLkzTCXt6A1w3GeJG6gx7JXJ2r ODJuk/aLx7cZCzvp9Wt2rXPbk4TJAeM9YHFgSCOix/14DtdjLwgD6CFRV86fj+vIaXMa 354bxf8iIraBCrLDKvlbztA/MY7Kje1ZpWSQ5uN3anMPEDaivZZwBs5QWEcoHJIs4HYS Ci2g==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hello,
how about detecting situations in the code like the following:
fun() { some code possibly returning false }
(( condition )) && fun || print "Some 'else'-instruction"
The warning would be triggered when:
- a an || would occur after an instruction preceded by &&,
- the instruction wouldn't be an always-true instruction, i.e. not
((1)), local var="value", etc. – this would also include prints etc.,
as the stdout can be closed and such instruction CAN fail – the
usefulness of the option is visible here, it would make the users
conscious of such fact.
Is this doable? To detect a preceding && and a following ||, and check
if the instruction is a function or a print?
The name of such option could be: warn_symmetric_cond, it would
describe the fact of symmetric way of condition processing.
To solve the warning, the users could e.g. convert the fun into { fun;
((1)) } or use an if.
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author