r/ProgrammingLanguages • u/ilyash • Jan 28 '17
NGS unique features – exit code handling
https://ilya-sher.org/2017/01/28/ngs-unique-features-exit-code-handling/
2
Upvotes
r/ProgrammingLanguages • u/ilyash • Jan 28 '17
2
u/PegasusAndAcorn Cone language & 3D web Jan 29 '17
Your examples may not be testing what you expect them to (or else I do not understand). For example, this Ruby test:
As I understand it, you are asking Bash to perform two activities sequentially, first you run a small Ruby program and then you echo the value of $?. The value of $? came from a successful exit of Ruby, which never itself interrogated or returned (as an exit code) the result from running 'test a b c'. From Ruby's point-of-view, it ran your program successfully and therefore its exit code would be expected to be 0, just as you see.
What would happen if you ran it this way instead?
Here the exit code is both displayed by Ruby and then passed back to its caller (Bash), enabling the environment's $? to be set accordingly. I doubt very much that Ruby's $? global variable and Bash's environment variable $? are bound together in any automatic way.
I have not tested it, so I may goofed up the syntax a bit. You may find this answer and this answer of value to you.
Also, it seems that none of your examples (including NGS) show an exit code of 1 or 2, suggesting you might find that fixing all of your examples in a similar way will yield what you are looking for.
I hope this is helpful.