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

Feature request: a new warning option

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