Code review comment for lp:~kirkland/ubuntu-dev-tools/612267

Revision history for this message
Stefano Rivera (stefanor) wrote :

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))

« Back to merge proposal