Documente Academic
Documente Profesional
Documente Cultură
/usr/bin/sh
#
# errno - quick lookup into /usr/include/sys/errno.h
# and crossreference to man page errno(2) for a fuller explanation
#
# usage: errno [ NUMBER | Emessage | -f ]
# where: NUMBER is errno number,
# Emessage is case-insensitive (eg: efault or EAGAIN)
#
# The script is smart enough to determine if an error number or
# the error name was used and to match only on the correct field
# in errno.h
set -u
PATH=/usr/bin
ERRNOFILE=/usr/include/sys/errno.h
MYNAME=${0##*/}
function AllNumbers
{
if [ $# -lt 1 ]
then
echo "Usage:"
echo " $MYNAME [ NUMBER | Emessage ]"
echo " where: NUMBER is errno number such as 12 or"
echo " Emessage is the text version such as ENOMEM"
echo " NOTE: Emessage can be lower or UPPER case"
exit 1
fi
typeset -u ERRTEXT=$1
AllNumbers $ERRTEXT
if [ $? -eq 0 ]
then
CHECKFIELD=3
else
CHECKFIELD=2
fi
# To make the search string dynamic, we'll let the shell expand
# the variable before awk sees it (AWK book pg 256)
if [ "$ERRLINE" = "" ]
then
echo "\n$MYNAME: nothing matched in $ERRNOFILE\n"
exit 0
fi
# Use typeset to line up the fields better than tabs (some fields > 8)