From 38624a82ea54bff1a8f3d7bdded22dbc084d58da Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 17 Jun 2010 10:59:40 -0700 Subject: [PATCH] Prefer ruby to do the magic, use python if no perl --- commonsh/10_utility | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commonsh/10_utility b/commonsh/10_utility index 666c833..4ad806c 100755 --- a/commonsh/10_utility +++ b/commonsh/10_utility @@ -10,11 +10,16 @@ unkey_host () err () { - if [ -e /usr/include/errno.h ] ; then + if ( command -v ruby > /dev/null 2>&1 ); then + ruby -e "Errno.constants.map{|errstr| errno = eval('Errno::' + errstr + '::Errno'); puts errstr if errno == $@}" + elif [ -e /usr/include/errno.h ] ; then cpp -dM /usr/include/errno.h | grep -w "E.* $@" fi + if ( command -v perl > /dev/null 2>&1 ) ; then perl -MPOSIX -e 'print strerror($ARGV[0])."\n";' $@ + elif ( command -v python > /dev/null 2>&1 ) ; then + python -c "import os;print(os.strerror($@))" fi }