Use exit codes instead of writing 0 and 1#1
Use exit codes instead of writing 0 and 1#1andlrc wants to merge 1 commit intocdax:masterfrom andlrc:master
0 and 1#1Conversation
This will enable usage like this:
setop is-empty < my_file && echo "File is empty..." || echo "File is NOT empty"
if setop is-empty < my_file; then
echo "Empty"
fi
|
Hey @ginkoms Thanks for your contribution! I agree with you in that this sort of usage would be really great when used from within other scripts. However, I'm sort of worried by the fact that nothing gets displayed on the console anymore when it's run as a standalone program, unless you explicitly print things based on the exit status. This worries me because this set of commands is directed mostly at people who're really new to bash (as I was, not so long ago when I started using these functions for the first time). Can we look for some sort of a middle ground here? Let me know if I'm missing something obvious. |
|
@cdax You can check to see if However using
Source: http://www.tldp.org/LDP/abs/html/intandnonint.html However Alternative you both write output and exit with a status code: Then it can still be used in an What is happening is that the I hope this gives you an idea of your alternatives. I would suggest always using exit codes, and then either: Always printing |
This will enable usage like this: