Use exit codes that actually means something.

source <(egrep '^#define EX_.*' /usr/include/sysexits.h | sed -e 's/#define/declare -r/g' | sed 's/\//#/g' | sed -e 's/\s\{1,\}/ /g' | sed -e 's/ \([0-9]\)/\=\1/'g )
Use meaningful exit codes change "source" to "cat" to view output instead of assigning
Sample Output
declare -r EX__BASE=64 #* base value for error messages *#
declare -r EX_USAGE=64 #* command line usage error *#
declare -r EX_DATAERR=65 #* data format error *#
declare -r EX_NOINPUT=66 #* cannot open input *#
declare -r EX_NOUSER=67 #* addressee unknown *#
declare -r EX_NOHOST=68 #* host name unknown *#
declare -r EX_UNAVAILABLE=69 #* service unavailable *#
declare -r EX_SOFTWARE=70 #* internal software error *#
declare -r EX_OSERR=71 #* system error (e.g., can't fork) *#
declare -r EX_OSFILE=72 #* critical OS file missing *#
declare -r EX_CANTCREAT=73 #* can't create (user) output file *#
declare -r EX_IOERR=74 #* input#output error *#
declare -r EX_TEMPFAIL=75 #* temp failure; user is invited to retry *#
declare -r EX_PROTOCOL=76 #* remote error in protocol *#
declare -r EX_NOPERM=77 #* permission denied *#
declare -r EX_CONFIG=78 #* configuration error *#
declare -r EX__MAX=78 #* maximum listed value *#

-1
2012-09-21 13:30:37

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: