home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume32
/
acronyms
/
part03
/
whats
< prev
Wrap
Text File
|
1992-09-20
|
2KB
|
86 lines
#!/bin/sh
#
# NAME
# whats - lookup acronym/abbreviation in database
#
# SYNOPSIS
# whats [acronym [defn...]]
#
# DESCRIPTION
# Whats, without any arguments, prompts for an acronym to look up.
#
# With one argument, whats prints all entries from the database
# that match the argument. If no matches are found, whats
# prompts for expansion of the acronym or abbreviation.
#
# With more than one argument, whats scans the database for
# entries matching the first argument. If any matches are found,
# whats prints the matching entries and asks if the remaining
# arguments should be added as a new entry. If no matches are
# found, a new entry is created for the first argument with the
# remaining arguments forming the expansion.
#
# FILES
# acron or $ACRON
#
# BUGS/DEFICIENCIES
# Not blindingly fast.
# Not tested under System V. (Uses "echo -n", "grep -i")
#
# AUTHOR
# Dave Sill (dsill@nswc-oas.arpa) (de5@ornl.gov as of 6/90)
# Naval Surface Warfare Center (NSWC), Dahlgren, VA
#
n='-n' # Use '' if your echo uses '\c'
c='' # Use '\c' if your echo uses it
q='-i' # Use '' or your grep's "ignore case" flag
if [ -z "$1" ]
then
echo $n "What is what? $c"
read ac
else
ac=$1
fi
ac=`echo ${ac} | tr "[a-z]" "[A-Z]"`
if [ ! -f acron ]
then
acron=${ACRON}
else
acron=acron
fi
i=`grep $q -c "^${ac} " ${acron}`
if [ -z "$2" -a $i -ne 0 ]
then
# No definition passed and is on file, so just do a lookup.
grep $q "^${ac} " ${acron}
exit
elif [ $i -ne 0 ]
then
# Is on file and a definition was passed, check before adding.
echo $i occurrences found.
grep $q "^${ac} " ${acron}
echo $n "Still want to add ${ac}? $c"
read reply
if [ "${reply}" = n -o "${reply}" = N ]
then
exit
fi
fi
if [ -z "$2" ]
then
echo $n "What does ${ac} stand for? $c"
read def
if [ -z "${def}" ]
then
exit
fi
else
shift
def=$*
fi
echo "${ac} - ${def}" >>${acron}
echo "${ac} - ${def}"