Skip to content

Commit 3f0f346

Browse files
committed
[zshrc] cleanup "err" function
1 parent 344de12 commit 3f0f346

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

commonsh/10_utility

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ err ()
2424
errno=`ruby -e "puts Errno::${errconst}::Errno" 2>/dev/null`
2525
fi
2626
if [ "${errno}" = "" ] && [ -e /usr/include/errno.h ] ; then
27-
errno=`cpp -dM /usr/include/errno.h | grep -E "${errconst}[[:space:]]+[0-9]+$" | grep -oE '[0-9]+' 2>/dev/null`
27+
errno=`cpp -E -dM /usr/include/errno.h | grep -E "${errconst}[[:space:]]+[0-9]+$" | grep -oE '[0-9]+' 2>/dev/null`
2828
fi
2929

3030
if [ "${errno}" ] ; then
@@ -37,7 +37,7 @@ err ()
3737
errno=$1
3838
unset errconst
3939
if [ "${errconst}" = "" ] && command -v ruby > /dev/null 2>&1 ; then
40-
errconst=`ruby -e "puts Errno.constants.find_all{|err| eval('Errno::' + err + '::Errno') == ${errno} }" 2>/dev/null`
40+
errconst=`ruby -e "puts Errno.constants.find_all{|err| Errno.const_get(err)::Errno == ${errno} }" 2>/dev/null`
4141
fi
4242
if [ "${errconst}" = "" ] && command -v python > /dev/null 2>&1 ; then
4343
errconst=`python -c "import errno;print(errno.errorcode[${errno}])" 2>/dev/null`
@@ -46,7 +46,7 @@ err ()
4646
errconst="${errconst} = ${errno}"
4747
fi
4848
if [ "${errconst}" = "" ] && [ -e /usr/include/errno.h ] ; then
49-
errconst=`cpp -dM /usr/include/errno.h | grep -E "E[[:alnum:]]+[[:space:]]+${errno}$"`
49+
errconst=`cpp -E -dM /usr/include/errno.h | grep -E "E[[:alnum:]]+[[:space:]]+${errno}$"`
5050
fi
5151

5252
if [ "${errconst}" ] ; then

0 commit comments

Comments
 (0)