Skip to content

Get the exit code from a command without capturing? #5286

Answered by gforsyth
halloleo asked this question in Q&A
Discussion options

You must be logged in to vote

You can use ![] for this. That creates a subproc pipeline that doesn't capture output, but has all of the other attributes of !().

ls
# a  b
a = ![ls .]  # note that output is not captured and streams to stdout
# a  b
a.returncode
# 0
a.output  # no output captured
# ''

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@anki-code
Comment options

@halloleo
Comment options

Answer selected by anki-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants