It would of course be rather out of place in moreutils too (which is mostly shell-scripting and pipe-related).
Also, this can be done far less evilly in about the same amount python (although it could use some better argument parsing and help string generation):
#!/usr/bin/python
from errno import errorcode
from os import strerror
import sys
import re
if sys.argv[1].isdigit():
found = (int(sys.argv[1]),)
else:
r = re.compile(sys.argv[1])
found = [i for i in errorcode.iterkeys()
if r.search(errorcode[i] + ' ' + strerror(i))]
for i in found:
print "%i: %s - %s" % (i, errorcode[i], strerror(i))
It would of course be rather out of place in moreutils too (which is mostly shell-scripting and pipe-related).
Also, this can be done far less evilly in about the same amount python (although it could use some better argument parsing and help string generation):
#!/usr/bin/python
from errno import errorcode
from os import strerror
import sys
import re
if sys.argv[ 1].isdigit( ): sys.argv[ 1]) iterkeys( ) errorcode[ i] + ' ' + strerror(i))]
found = (int(sys.argv[1]),)
else:
r = re.compile(
found = [i for i in errorcode.
if r.search(
for i in found:
print "%i: %s - %s" % (i, errorcode[i], strerror(i))