diff options
author | Lars Wirzenius <liw@liw.fi> | 2009-02-03 12:48:06 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2009-02-03 12:48:06 +0200 |
commit | 7ddb4d64810f3e58b43798de7f2dc2bf67df59d5 (patch) | |
tree | 1643b961bae8468ce09d4e36dcf5b57715840d56 | |
parent | a71f4cce9ad601767102109afb4fed6dd7f7b95f (diff) | |
download | extrautils-7ddb4d64810f3e58b43798de7f2dc2bf67df59d5.tar.gz |
Added errno.
-rwxr-xr-x | errno | 16 | ||||
-rw-r--r-- | errno.1 | 51 |
2 files changed, 67 insertions, 0 deletions
@@ -0,0 +1,16 @@ +#!/usr/bin/python + +import errno +import os +import sys + +toname = dict((str(getattr(errno, x)), x) for x in dir(errno) if x.startswith("E")) +tocode = dict((x, getattr(errno, x)) for x in dir(errno) if x.startswith("E")) + +for arg in sys.argv[1:]: + if arg in tocode: + print arg, tocode[arg], os.strerror(tocode[arg]) + elif arg in toname: + print toname[arg], arg, os.strerror(int(arg)) + else: + print "Unknown:", arg @@ -0,0 +1,51 @@ +.\" errno.1 - manual page for the errno command +.\" Copyright (C) 2009 Lars Wirzenius +.\" +.\" This program is free software: you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see <http://www.gnu.org/licenses/>. +.\" +.TH ERRNO 1 +.SH NAME +errno \- look up errno codes or names +.SH SYNOPSIS +.B errno +.RI [ code | name ]... +.SH DESCRIPTION +.B errno +prints the description of +.BR errno (3) +values, from the command line. +It can look descriptions based on the numeric code or names like +.BR EEXIST . +.PP +For example, to look up what the code 2 means: +.sp 1 +.nf +.RS +$ errno 2 +ENOENT 2 No such file or directory +.RE +.fi +.sp 1 +Similarly, to look up what the code EEXIST means: +.sp 1 +.nf +.RS +$ errno EEXIST +EEXIST 17 File exists +.RE +.fi +.sp 1 +Note that the output always lists both the name and the code. +.SH "SEE ALSO" +.BR errno (3). |