[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8090: strerror(1) and strsignal(1)?
From: |
Jim Meyering |
Subject: |
bug#8090: strerror(1) and strsignal(1)? |
Date: |
Mon, 21 Feb 2011 17:16:49 +0100 |
Alan Curry wrote:
> Bruce Korb writes:
>>
>> Hi Jim,
>>
>> On 02/20/11 15:20, Jim Meyering wrote:
>> > Bruce Korb wrote:
>> > Hi Bruce,
>> >
>> > [your subject mentions strsignal -- you know you can get a list
>> > via "env kill --table", assuming you have kill from coreutils? ]
>
> What's the installation rate of coreutils-kill vs. procps kill? Debian
> chooses procps kill (except on Hurd and maybe freebsd-kernel)
Actually, you can also use shell-builtin functions, so
whether coreutils' kill program is installed matters less:
$ bash -c 'builtin kill -l 3'
SIGQUIT
$ zsh -c 'builtin kill -l 3'
QUIT
>> > I've had that itch many times.
>> > Here are some handy bash/perl functions I wrote:
>>
>> Yep. I know one can get to it via perl. OTOH, _you've_ had that
>> itch many times, Padraig's had that itch many times, and I'd take
>> a wild guess that there have been a few others, too. So it still
>
> You guys don't perl-golf well.
>
> perl -E'say$!=11'
>
> or for older perls
>
> perl -le'print$!=11'
Those are cute, and no doubt minimal,
but for something like this, I would favor readability
(yeah, the quotes make it ugly) over minimality:
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 $!'
}