Sunday, January 10, 2010

StdError Description in scripts

I never actually went that deep into the C code to understand the stderror codes that are returned in common bash scripts.

Recently, on a discussion thread from CoreUtils group, a simple implementation of error code translation caught my attention. Instead of relying on the errno.h file (which contains the list of errors with their respective brief description), you can incorporate secondary scripts (Perl, or Python) to do this job for you.

Thanks to Pádraig Brady for this:

$ test || python -c "import os; print $?, os.strerror($?);"
(you could just wrap this in a function).

No comments:

Post a Comment