GNU bug report logs - #8090
new programs: strerror(1) and strsignal(1)?

Previous Next

Package: coreutils;

Reported by: Bruce Korb <bruce.korb <at> gmail.com>

Date: Sun, 20 Feb 2011 22:44:02 UTC

Severity: wishlist

Tags: wontfix

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 8090 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Bruce Korb <bruce.korb <at> gmail.com>
Cc: 8090 <at> debbugs.gnu.org
Subject: Re: bug#8090: strerror(1) and strsignal(1)?
Date: Mon, 21 Feb 2011 00:20:24 +0100
Bruce Korb wrote:
> I had to go grubbing through headers to translate "11" into something
> comprehensible one too many times.  If this is acceptable, I'll double
> my time investment and whip up some .texi verbiage.
>
> I believe my paperwork is in order, but I'm not convinced that this
> qualifies as "significant" :-D.

Hi Bruce,

[your subject mentions strsignal -- you know you can get a list
 via "env kill --table", assuming you have kill from coreutils? ]

I've had that itch many times.
Here are some handy bash/perl functions I wrote:

    $ errno-find 11
    EAGAIN
    $ errno-int-to-msg 11
    Resource temporarily unavailable
    $ errno-sym-to-int EAGAIN
    11


# Print a table of names/values/messages:
errno-table()
{
  perl -MErrno -e 'my %e= map { Errno->$_()=>$_ } keys %!;' \
    -e 'print grep !/unknown error/i,' \
    -e 'map sprintf("%4d %-12s %s".$/,$_,$e{$_},$!=$_), 0..256'
}

# map errno integer to message, e.g., 2 to No such file or directory
errno-int-to-msg()
{
  local fail=0
  case $# in 1) case $1 in [0-9]*) ;; *) fail=1;; esac;; *) fail=1;; esac
  test $fail = 1 && { echo "Usage: $FUNCNAME ERRNO_INT" 1>&2; return 1; }
  perl -le '$!='"$1"'; print $!'
}

# map errno symbolic name to integer, e.g., ENOSYS to 28
errno-sym-to-int()
{
  local fail=0
  case $# in 1) case $1 in [0-9]*) fail=1;; esac;; *) fail=1;; esac
  test $fail = 1 && { echo "Usage: $FUNCNAME ERRNO_SYM" 1>&2; return 1; }
  perl -le "use Errno '$1'; print $1"
}

errno-find()
{
  case $# in
    1) ;;
    *) echo "Usage: $FUNCNAME ERRNO_VALUE" 1>&2; return 1;;
  esac
  perl -MErrno -le 'my %e=map { Errno->$_()=>$_ } keys %!; print $e{'"$1"'}'
}




This bug report was last modified 6 years and 269 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.