Permalink
Browse files

[zshrc] cleanup "err" function

  • Loading branch information...
1 parent 344de12 commit 3f0f346b922c4c9027fbe1e0f4930e7fb0d0c6cc @majnemer committed Aug 16, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 commonsh/10_utility
View
6 commonsh/10_utility
@@ -24,7 +24,7 @@ err ()
errno=`ruby -e "puts Errno::${errconst}::Errno" 2>/dev/null`
fi
if [ "${errno}" = "" ] && [ -e /usr/include/errno.h ] ; then
- errno=`cpp -dM /usr/include/errno.h | grep -E "${errconst}[[:space:]]+[0-9]+$" | grep -oE '[0-9]+' 2>/dev/null`
+ errno=`cpp -E -dM /usr/include/errno.h | grep -E "${errconst}[[:space:]]+[0-9]+$" | grep -oE '[0-9]+' 2>/dev/null`
fi
if [ "${errno}" ] ; then
@@ -37,7 +37,7 @@ err ()
errno=$1
unset errconst
if [ "${errconst}" = "" ] && command -v ruby > /dev/null 2>&1 ; then
- errconst=`ruby -e "puts Errno.constants.find_all{|err| eval('Errno::' + err + '::Errno') == ${errno} }" 2>/dev/null`
+ errconst=`ruby -e "puts Errno.constants.find_all{|err| Errno.const_get(err)::Errno == ${errno} }" 2>/dev/null`
fi
if [ "${errconst}" = "" ] && command -v python > /dev/null 2>&1 ; then
errconst=`python -c "import errno;print(errno.errorcode[${errno}])" 2>/dev/null`
@@ -46,7 +46,7 @@ err ()
errconst="${errconst} = ${errno}"
fi
if [ "${errconst}" = "" ] && [ -e /usr/include/errno.h ] ; then
- errconst=`cpp -dM /usr/include/errno.h | grep -E "E[[:alnum:]]+[[:space:]]+${errno}$"`
+ errconst=`cpp -E -dM /usr/include/errno.h | grep -E "E[[:alnum:]]+[[:space:]]+${errno}$"`
fi
if [ "${errconst}" ] ; then

0 comments on commit 3f0f346

Please sign in to comment.