zsh-users
 help / color / mirror / code / Atom feed
* Feature request: a new warning option
@ 2019-10-09  4:02 Sebastian Gniazdowski
  2019-10-09  8:45 ` Roman Perepelitsa
  2019-10-09 18:15 ` Bart Schaefer
  0 siblings, 2 replies; 15+ messages in thread
From: Sebastian Gniazdowski @ 2019-10-09  4:02 UTC (permalink / raw)
  To: Zsh Users

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-10-10  3:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-09  4:02 Feature request: a new warning option Sebastian Gniazdowski
2019-10-09  8:45 ` Roman Perepelitsa
2019-10-09  8:49   ` Peter Stephenson
2019-10-09 11:56   ` Sebastian Gniazdowski
2019-10-09 12:08     ` Roman Perepelitsa
2019-10-09 13:17       ` Sebastian Gniazdowski
2019-10-09 13:24         ` Peter Stephenson
2019-10-09 13:41           ` Sebastian Gniazdowski
2019-10-09 14:07             ` Ray Andrews
2019-10-09 15:19               ` Peter Stephenson
     [not found]           ` <CAKc7PVBQnt_ZE3X=8gz5R_VURwaTL3mDL=X-7H__yYqAjvXoWA__41912.055101578$1570628583$gmane$org@mail.gmail.com>
2019-10-09 14:04             ` Stephane Chazelas
2019-10-09 13:40         ` Roman Perepelitsa
2019-10-09 17:36           ` Daniel Shahaf
2019-10-09 18:15 ` Bart Schaefer
2019-10-10  3:29   ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).