summaryrefslogtreecommitdiffstats
path: root/etc/isdn
diff options
context:
space:
mode:
authorsheldonh <sheldonh@FreeBSD.org>1999-09-13 15:44:20 +0000
committersheldonh <sheldonh@FreeBSD.org>1999-09-13 15:44:20 +0000
commitd8a93d30ec0f7b9de2d59dab07ac29c6f7f8f663 (patch)
treef61d8b7d858e07792674c281853167482e6806c5 /etc/isdn
parent019fd9cb5fe17ed3ce93a28306ec3009d2a512f7 (diff)
downloadFreeBSD-src-d8a93d30ec0f7b9de2d59dab07ac29c6f7f8f663.zip
FreeBSD-src-d8a93d30ec0f7b9de2d59dab07ac29c6f7f8f663.tar.gz
Apply a consistent style to most of the etc scripts. Particularly, use
case instead of test where appropriate, since case allows case is a sh builtin and (as a side-effect) allows case-insensitivity. Changes discussed on freebsd-hackers. Submitted by: Doug Barton <Doug@gorean.org>
Diffstat (limited to 'etc/isdn')
-rwxr-xr-xetc/isdn/answer103
-rwxr-xr-xetc/isdn/isdntel.sh61
-rwxr-xr-xetc/isdn/record104
-rwxr-xr-xetc/isdn/tell90
-rwxr-xr-xetc/isdn/tell-record92
5 files changed, 200 insertions, 250 deletions
diff --git a/etc/isdn/answer b/etc/isdn/answer
index df9e804..d39a983 100755
--- a/etc/isdn/answer
+++ b/etc/isdn/answer
@@ -17,92 +17,81 @@ VARDIR=/var/isdn
LIBDIR=/usr/share/isdn
LOGFILE=/tmp/answer.log
-NCALLFILE=$VARDIR/ncall
+NCALLFILE=${VARDIR}/ncall
DATE=`date +%d%H`
DF=0
dF=0
sF=0
-set -- `getopt D:d:s: $*`
-
-if test $? != 0
-then
+if ! set -- `getopt D:d:s: $*`; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
fi
-for i
-do
- case "$i"
- in
- -D)
- DEVICE=$2
- DF=1
- shift
- shift
- ;;
- -d)
- DEST=$2
- dF=1
- shift
- shift
- ;;
- -s)
- SRC=$2
- sF=1
- shift
- shift
- ;;
- --)
- shift
- break
- ;;
+for i ; do
+ case ${i} in
+ -D)
+ DEVICE=$2
+ DF=1
+ shift
+ shift
+ ;;
+ -d)
+ DEST=$2
+ dF=1
+ shift
+ shift
+ ;;
+ -s)
+ SRC=$2
+ sF=1
+ shift
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
esac
done
-echo "" >>$LOGFILE
+echo "" >>${LOGFILE}
-if [ $DF -eq 0 -o $dF -eq 0 -o $sF -eq 0 ]
-then
+if [ "${DF}" -eq 0 -o "${dF}" -eq 0 -o "${sF}" -eq 0 ]; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
-fi
+fi
-echo "answer: device $DEVICE destination $DEST source $SRC " >>$LOGFILE
+echo "answer: device ${DEVICE} destination ${DEST} source ${SRC} " >>${LOGFILE}
-if [ -f $NCALLFILE ]
-then
- NCALL=`cat $NCALLFILE`
-else
+if [ -r "${NCALLFILE}" ]; then
+ NCALL=`cat ${NCALLFILE}`
+else
NCALL=0
fi
-NCALL=`printf "%.4d" $NCALL`
+NCALL=`printf "%.4d" ${NCALL}`
-echo Date: `date` >> $VARDIR/I.$NCALL.$DATE
+echo Date: `date` >> ${VARDIR}/I.${NCALL}.${DATE}
-if [ "$SRC" != "" ]
-then
- echo "From: $SRC" >> $VARDIR/I.$NCALL.$DATE
+if [ -n "${SRC}" ]; then
+ echo "From: ${SRC}" >> ${VARDIR}/I.${NCALL}.${DATE}
fi
-if [ "$DEST" != "" ]
-then
- echo "To: $DEST" >> $VARDIR/I.$NCALL.$DATE
+if [ -n "${DEST}" ]; then
+ echo "To: ${DEST}" >> ${VARDIR}/I.${NCALL}.${DATE}
fi
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k # >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k # >/dev/null 2>&1
fi
-if [ -f $LIBDIR/msg.al ]
-then
- dd of=$DEVICE if=$LIBDIR/msg.al bs=2k # >/dev/null 2>&1
- if [ -f $LIBDIR/beep.al ]
+if [ -r "${LIBDIR}/msg.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/msg.al bs=2k # >/dev/null 2>&1
+ if [ -r "${LIBDIR}/beep.al" ]
then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k # >/dev/null 2>&1
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k # >/dev/null 2>&1
fi
fi
-echo `expr $NCALL + 1` >$NCALLFILE
+echo `expr ${NCALL} + 1` >${NCALLFILE}
diff --git a/etc/isdn/isdntel.sh b/etc/isdn/isdntel.sh
index d76885d..14f528a 100755
--- a/etc/isdn/isdntel.sh
+++ b/etc/isdn/isdntel.sh
@@ -17,9 +17,9 @@ LIBDIR=/usr/share/isdn
VARDIR=/var/isdn
DEVICE=/dev/i4btel0
-# sounds
-MESSAGE=$LIBDIR/msg.al
-BEEP=$LIBDIR/beep.al
+# sounds
+MESSAGE=${LIBDIR}/msg.al
+BEEP=${LIBDIR}/beep.al
# dd options
SKIP=25
@@ -35,36 +35,32 @@ dst=
DATE=`date`
# check if directory exists
-if [ ! -d $VARDIR ]
+if [ ! -d "${VARDIR}" ]
then
- mkdir $VARDIR
+ mkdir ${VARDIR}
fi
# get options
-set -- `/usr/bin/getopt D:d:s: $*`
-
-if [ $? != 0 ]
-then
+if ! set -- `/usr/bin/getopt D:d:s: $*`; then
echo "usage2: play -D device -d <dest-telno> -s <src-telno>"
exit 1
fi
# process options
-for i
-do
+for i ; do
case $i in
- -D)
- DEVICE=$2; shift; shift;
- ;;
- -d)
- dst=$2; shift; shift;
- ;;
- -s)
- src=$2; shift; shift;
- ;;
- --)
- shift; break;
- ;;
+ -D)
+ DEVICE=$2; shift; shift;
+ ;;
+ -d)
+ dst=$2; shift; shift;
+ ;;
+ -s)
+ src=$2; shift; shift;
+ ;;
+ --)
+ shift; break;
+ ;;
esac
done
@@ -73,33 +69,30 @@ done
FILEDATE=`date \+%y%m%d%H%M%S`
# echo message to phone
-if [ -f $MESSAGE ]
-then
- /bin/dd of=$DEVICE if=$MESSAGE bs=2k >/dev/null 2>&1
+if [ -r "${MESSAGE}" ]; then
+ /bin/dd of=${DEVICE} if=${MESSAGE} bs=2k >/dev/null 2>&1
fi
# echo beep to phone
-if [ -f $BEEP ]
-then
- /bin/dd of=$DEVICE if=$BEEP bs=2k >/dev/null 2>&1
+if [ -r "${BEEP}" ]; then
+ /bin/dd of=${DEVICE} if=${BEEP} bs=2k >/dev/null 2>&1
fi
# start time
START=`date \+%s`
# get message from caller
-/bin/dd if=$DEVICE of=$VARDIR/$FILEDATE-$dst-$src skip=$SKIP bs=2k count=$MAXMSIZ >/dev/null 2>&1
+/bin/dd if=${DEVICE} of=${VARDIR}/${FILEDATE}-${dst}-${src} skip=${SKIP} bs=2k count=${MAXMSIZ} >/dev/null 2>&1
# end time
END=`date \+%s`
# duration
-TIME=`expr $END - $START`
+TIME=`expr ${END} - ${START}`
# save recorded message
-if [ -f $VARDIR/$FILEDATE-$dst-$src ]
-then
- mv $VARDIR/$FILEDATE-$dst-$src $VARDIR/$FILEDATE-$dst-$src-$TIME
+if [ -r "${VARDIR}/${FILEDATE}-${dst}-${src}" ]; then
+ mv ${VARDIR}/${FILEDATE}-${dst}-${src} ${VARDIR}/${FILEDATE}-${dst}-${src}-${TIME}
fi
exit 0
diff --git a/etc/isdn/record b/etc/isdn/record
index 24e6cd6..61591fb 100755
--- a/etc/isdn/record
+++ b/etc/isdn/record
@@ -17,95 +17,83 @@ VARDIR=/var/isdn
LIBDIR=/usr/share/isdn
LOGFILE=/tmp/answer.log
-NCALLFILE=$VARDIR/ncall
+NCALLFILE=${VARDIR}/ncall
DATE=`date +%d%H`
DF=0
dF=0
sF=0
-set -- `getopt D:d:s: $*`
-
-if test $? != 0
-then
+if ! set -- `getopt D:d:s: $*`; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
fi
-for i
-do
- case "$i"
- in
- -D)
- DEVICE=$2
- DF=1
- shift
- shift
- ;;
- -d)
- DEST=$2
- dF=1
- shift
- shift
- ;;
- -s)
- SRC=$2
- sF=1
- shift
- shift
- ;;
- --)
- shift
- break
- ;;
+for i ; do
+ case ${i} in
+ -D)
+ DEVICE=$2
+ DF=1
+ shift
+ shift
+ ;;
+ -d)
+ DEST=$2
+ dF=1
+ shift
+ shift
+ ;;
+ -s)
+ SRC=$2
+ sF=1
+ shift
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
esac
done
-echo "" >>$LOGFILE
+echo "" >>${LOGFILE}
-if [ $DF -eq 0 -o $dF -eq 0 -o $sF -eq 0 ]
-then
+if [ "${DF}" -eq 0 -o "${dF}" -eq 0 -o "${sF}" -eq 0 ]; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
-fi
+fi
-echo "answer: device $DEVICE destination $DEST source $SRC " >>$LOGFILE
+echo "answer: device ${DEVICE} destination ${DEST} source ${SRC} " >>${LOGFILE}
-if [ -f $NCALLFILE ]
-then
- NCALL=`cat $NCALLFILE`
-else
+if [ -r "${NCALLFILE}" ]; then
+ NCALL=`cat ${NCALLFILE}`
+else
NCALL=0
fi
-NCALL=`printf "%.4d" $NCALL`
+NCALL=`printf "%.4d" ${NCALL}`
-echo Date: `date` >> $VARDIR/I.$NCALL.$DATE
+echo Date: `date` >> ${VARDIR}/I.${NCALL}.${DATE}
-if [ "$SRC" != "" ]
-then
- echo "From: $SRC" >> $VARDIR/I.$NCALL.$DATE
+if [ -n "${SRC}" ]; then
+ echo "From: ${SRC}" >> ${VARDIR}/I.${NCALL}.${DATE}
fi
-if [ "$DEST" != "" ]
-then
- echo "To: $DEST" >> $VARDIR/I.$NCALL.$DATE
+if [ -n "${DEST}" ]; then
+ echo "To: ${DEST}" >> ${VARDIR}/I.${NCALL}.${DATE}
fi
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
fi
-if [ -f $LIBDIR/msg.al ]
-then
- dd of=$DEVICE if=$LIBDIR/msg.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/msg.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/msg.al bs=2k >/dev/null 2>&1
fi
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
fi
-dd if=$DEVICE of=$VARDIR/R.$NCALL.$DATE bs=2k >/dev/null 2>&1
+dd if=${DEVICE} of=${VARDIR}/R.${NCALL}.${DATE} bs=2k >/dev/null 2>&1
echo `expr $NCALL + 1` >$NCALLFILE
diff --git a/etc/isdn/tell b/etc/isdn/tell
index 7bdd10a..047c834 100755
--- a/etc/isdn/tell
+++ b/etc/isdn/tell
@@ -17,81 +17,71 @@ VARDIR=/var/isdn
LIBDIR=/usr/share/isdn
LOGFILE=/tmp/answer.log
-NCALLFILE=$VARDIR/ncall
+NCALLFILE=${VARDIR}/ncall
DATE=`date +%d%H`
DF=0
dF=0
sF=0
-set -- `getopt D:d:s: $*`
-
-if test $? != 0
-then
+if ! set -- `getopt D:d:s: $*`; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
fi
-for i
-do
- case "$i"
- in
- -D)
- DEVICE=$2
- DF=1
- shift
- shift
- ;;
- -d)
- DEST=$2
- dF=1
- shift
- shift
- ;;
- -s)
- SRC=$2
- sF=1
- shift
- shift
- ;;
- --)
- shift
- break
- ;;
+for i ; do
+ case ${i} in
+ -D)
+ DEVICE=$2
+ DF=1
+ shift
+ shift
+ ;;
+ -d)
+ DEST=$2
+ dF=1
+ shift
+ shift
+ ;;
+ -s)
+ SRC=$2
+ sF=1
+ shift
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
esac
done
-echo "" >>$LOGFILE
+echo "" >>${LOGFILE}
-if [ $DF -eq 0 -o $dF -eq 0 -o $sF -eq 0 ]
-then
+if [ "${DF}" -eq 0 -o "${dF}" -eq 0 -o "${sF}" -eq 0 ]; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
-fi
+fi
-echo "answer: device $DEVICE destination $DEST source $SRC " >>$LOGFILE
+echo "answer: device ${DEVICE} destination ${DEST} source ${SRC} " >>${LOGFILE}
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
fi
# tell the caller the number he is calling from
POS=1
-LENGTH=`expr $SRC : '.*'`
+LENGTH=`expr ${SRC} : '.*'`
-while :
-do
- DIGIT=`echo $SRC | cut -c $POS`
- /bin/dd of=$DEVICE if=$LIBDIR/$DIGIT.al bs=2k >/dev/null 2>&1
- POS=`expr $POS + 1`
- if [ $POS -gt $LENGTH ]
- then
+while : ; do
+ DIGIT=`echo ${SRC} | cut -c ${POS}`
+ /bin/dd of=${DEVICE} if=${LIBDIR}/${DIGIT}.al bs=2k >/dev/null 2>&1
+ POS=`expr ${POS} + 1`
+ if [ "${POS}" -gt "${LENGTH}" ]; then
break
fi
done
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
fi
diff --git a/etc/isdn/tell-record b/etc/isdn/tell-record
index d5c356c..b081a0f 100755
--- a/etc/isdn/tell-record
+++ b/etc/isdn/tell-record
@@ -17,83 +17,73 @@ VARDIR=/var/isdn
LIBDIR=/usr/share/isdn
LOGFILE=/tmp/answer.log
-NCALLFILE=$VARDIR/ncall
+NCALLFILE=${VARDIR}/ncall
DATE=`date +%d%H`
DF=0
dF=0
sF=0
-set -- `getopt D:d:s: $*`
-
-if test $? != 0
-then
+if ! set -- `getopt D:d:s: $*`; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
fi
-for i
-do
- case "$i"
- in
- -D)
- DEVICE=$2
- DF=1
- shift
- shift
- ;;
- -d)
- DEST=$2
- dF=1
- shift
- shift
- ;;
- -s)
- SRC=$2
- sF=1
- shift
- shift
- ;;
- --)
- shift
- break
- ;;
+for i ; do
+ case ${i} in
+ -D)
+ DEVICE=$2
+ DF=1
+ shift
+ shift
+ ;;
+ -d)
+ DEST=$2
+ dF=1
+ shift
+ shift
+ ;;
+ -s)
+ SRC=$2
+ sF=1
+ shift
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
esac
done
-echo "" >>$LOGFILE
+echo "" >>${LOGFILE}
-if [ $DF -eq 0 -o $dF -eq 0 -o $sF -eq 0 ]
-then
+if [ "${DF}" -eq 0 -o "${dF}" -eq 0 -o "${sF}" -eq 0 ]; then
echo 'Usage: answer -D device -d destination -s source'
exit 1
-fi
+fi
-echo "answer: device $DEVICE destination $DEST source $SRC " >>$LOGFILE
+echo "answer: device ${DEVICE} destination ${DEST} source ${SRC} " >>${LOGFILE}
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
fi
# tell the caller the number he is calling from
POS=1
-LENGTH=`expr $SRC : '.*'`
+LENGTH=`expr ${SRC} : '.*'`
-while :
-do
- DIGIT=`echo $SRC | cut -c $POS`
- /bin/dd of=$DEVICE if=$LIBDIR/$DIGIT.al bs=2k >/dev/null 2>&1
- POS=`expr $POS + 1`
- if [ $POS -gt $LENGTH ]
- then
+while : ; do
+ DIGIT=`echo ${SRC} | cut -c ${POS}`
+ /bin/dd of=${DEVICE} if=${LIBDIR}/${DIGIT}.al bs=2k >/dev/null 2>&1
+ POS=`expr ${POS} + 1`
+ if [ "${POS}" -gt "${LENGTH}" ]; then
break
fi
done
-if [ -f $LIBDIR/beep.al ]
-then
- dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
+if [ -r "${LIBDIR}/beep.al" ]; then
+ dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
fi
-dd if=$DEVICE of=$VARDIR/recorded.msg bs=2k
+dd if=${DEVICE} of=${VARDIR}/recorded.msg bs=2k
OpenPOWER on IntegriCloud