argh icon indicating copy to clipboard operation
argh copied to clipboard

raising CommandError leaves returncode as 0

Open sanga opened this issue 8 years ago • 2 comments

It feels a bit weird as if you raise a CommandError then presumably the program hasn't succeeded in which case I'd expected returncode to be nonzero so that a script would know programmatically that something failed.

sanga avatar Sep 25 '16 14:09 sanga

Came here to post this, but it looks like this has been inactive for 2 years? This is a serious bug, where scripts fail but report that they succeed.

If the concern is backwards compatability, I suggest deprecating CommandError with its broken behaviour, and replacing it with something equivalent (eg. CommandFailed) which allows the exit code to be set, with the default being 1.

A less drastic option would be to add the ability to set the exit code in a CommandError, but have it default to 0. This is a smaller change but leaves the default as being dangerous and broken, which is definitely not ideal.

ekimekim avatar Aug 25 '18 05:08 ekimekim

Just to make some noise for the benefit of #124, this is a pretty serious issue still, another two years later.

acetylen avatar Feb 27 '20 12:02 acetylen

@ekimekim thanks for raising the issue and fixing it in yaargh. Would you mind if I port https://github.com/ekimekim/yaargh/pull/12 to Argh?

P.S.: I've taken a closer look at what you did in Yaargh in terms of analysis, code and documentation. If you're interested in contributing to Argh, I'd really rather ask you to take care of integration of this behaviour into Argh as your expertise on this topic is clearly deeper than mine at this point.

In general the projects seem to have diverged a bit in one particular aspect (support for help-via-annotations was improved in Yaargh but is about to be removed in Argh in favour of #107) but otherwise it would be great if we could combine our resources.

neithere avatar Feb 10 '23 14:02 neithere

Would you mind if I port https://github.com/ekimekim/yaargh/pull/12 to Argh?

That would be great!

I'd really rather ask you to take care of integration of this behaviour into Argh as your expertise on this topic is clearly deeper than mine at this point.

To be honest I haven't really worked on this at all in a few years, but I'd love to help. I'll get started on an upstreamable version of https://github.com/ekimekim/yaargh/pull/12 and we'll see how it goes.

ekimekim avatar Feb 11 '23 00:02 ekimekim