On Wed, Apr 29, 2020 at 05:07:56PM +0200, Julia Lawall wrote: > > > On Wed, 29 Apr 2020, Paul Chaignon wrote: > > > Hi everyone, > > > > I am trying to exit spatch with a non-zero exit status when required > > changes have been found. I have tried to add a rule with finalize:python > > and the following code: > > > > @finalize:python@ > > @@ > > exit(cnt) > > > > where cnt is incremented by another Python rule everytime a required > > change is found. This works as expected except for the --in-place option > > which becomes ineffective. > > > > Is this a bug, or is finalize:python not intended to be used in that > > manner? Is it possible to overwrite spatch's exit status? > > I'm actually surprised that this would ever work... > > Finalize was intended for processing information in general, eg printing > some statistics about what was matched. > > Would it be feasible to print cnt instead?
Sure. I can easily get around this issue by e.g. grepping for spatch's messages in a wrapper script. Getting spatch to return a non-zero exit status is just a convenience. I thought that would be a fairly common use case. Thanks for the quick answer as always :) Paul > > julia _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
