Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is error handling inside pipeline possible? #145

Closed
spivachek opened this issue Aug 27, 2014 · 2 comments
Closed

Is error handling inside pipeline possible? #145

spivachek opened this issue Aug 27, 2014 · 2 comments

Comments

@spivachek
Copy link

In a pipeline we get exit code only from the last command. How can we know if one of the previous commands failed? Here is the code to show the problem:

from plumbum.cmd import yes, head

# 'head' gets incorrect argument, exit code = 1, ok
chain = yes | head["-x"]
print chain
print chain.run(retcode=None)

# 'yes' gets incorrect argument, exit code = 0 as if it's ok, bad
chain = yes["-x"] | head
print chain
print chain.run(retcode=None)

From the output we see that there is no trace of error in the second pipeline:

/usr/bin/yes | /usr/bin/head -x
(1, u'', u"head: unknown option -- x\nTry `/usr/bin/head --help' for more information.\n")
/usr/bin/yes -x | /usr/bin/head
(0, u'', u'')

Can we have something like 'pipefail' option or 'PIPESTATUS' array in Bash?

@tomerfiliba
Copy link
Owner

Yeap, that's looks like a bug. I'll have a look into it.

@leoncamel
Copy link

Please release a new version 1.4.3. The latest version at pypi is 1.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants