import games/wtf from NetBSD
closes #260 Change-Id: Ia3bbe28d77dff7f21fe7de3d0c03a65f6681049c
This commit is contained in:
parent
8e2f9ecaf4
commit
6ea41bd866
@ -37,6 +37,7 @@
|
|||||||
./usr/games/tetris minix-games
|
./usr/games/tetris minix-games
|
||||||
./usr/games/unstr minix-games
|
./usr/games/unstr minix-games
|
||||||
./usr/games/wargames minix-games
|
./usr/games/wargames minix-games
|
||||||
|
./usr/games/wtf minix-games
|
||||||
./usr/share minix-games
|
./usr/share minix-games
|
||||||
./usr/share/games minix-games
|
./usr/share/games minix-games
|
||||||
./usr/share/games/fish.instr minix-games
|
./usr/share/games/fish.instr minix-games
|
||||||
|
@ -15,7 +15,7 @@ SUBDIR= adventure arithmetic \
|
|||||||
monop morse number \
|
monop morse number \
|
||||||
pig ppt primes \
|
pig ppt primes \
|
||||||
rain random rogue snake tetris \
|
rain random rogue snake tetris \
|
||||||
wargames
|
wargames wtf
|
||||||
|
|
||||||
.if !defined(__MINIX)
|
.if !defined(__MINIX)
|
||||||
.if ${MKCXX} != "no"
|
.if ${MKCXX} != "no"
|
||||||
|
7
games/wtf/Makefile
Normal file
7
games/wtf/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# $NetBSD: Makefile,v 1.1 1999/07/22 01:03:20 mrg Exp $
|
||||||
|
|
||||||
|
SCRIPTS= wtf
|
||||||
|
SCRIPTSDIR= /usr/games
|
||||||
|
MAN= wtf.6
|
||||||
|
|
||||||
|
.include <bsd.prog.mk>
|
111
games/wtf/wtf
Normal file
111
games/wtf/wtf
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# $NetBSD: wtf,v 1.21 2015/04/21 23:56:30 christos Exp $
|
||||||
|
#
|
||||||
|
# Public domain
|
||||||
|
#
|
||||||
|
|
||||||
|
PROGNAME="$(basename "$0")"
|
||||||
|
offensive=false
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $PROGNAME [-o] [-f dbfile] [is] term ..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts f:o f
|
||||||
|
do
|
||||||
|
case "$f" in
|
||||||
|
o) offensive=true
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
acronyms="$OPTARG $acronyms"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift "$(expr "$OPTIND" - 1)"
|
||||||
|
|
||||||
|
if [ "$1" = "is" ]; then
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$acronyms" ]; then
|
||||||
|
if [ -z "$ACRONYMDB" ]; then
|
||||||
|
for f in /usr/share/misc/acronyms*; do
|
||||||
|
case $f in
|
||||||
|
*-o)
|
||||||
|
if $offensive; then
|
||||||
|
acronyms="$acronyms $f"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
acronyms="$acronyms $f"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
else
|
||||||
|
acronyms="$ACRONYMDB"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$acronyms" ]; then
|
||||||
|
echo "$PROGNAME: acronym database not found!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
for f in $acronyms; do
|
||||||
|
if [ ! -f $f ]; then
|
||||||
|
echo "$PROGNAME: cannot open acronym database file \`$f'" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
rv=0
|
||||||
|
for i; do
|
||||||
|
# Search acronym list first
|
||||||
|
target="$(echo "$i" | tr '[a-z]' '[A-Z]')"
|
||||||
|
ans="$(fgrep -h "$target" $acronyms 2>/dev/null \
|
||||||
|
| sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p")"
|
||||||
|
if [ -n "$ans" ] ; then
|
||||||
|
echo "$target: $ans"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try whatis(1) next
|
||||||
|
ans="$(whatis "$i" 2>/dev/null)"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "$ans" | sort -u
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try pkg_info(1) next
|
||||||
|
ans="$(pkg_info -qc "$i" 2> /dev/null)"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "$i: $ans"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If called from pkgsrc package directory,
|
||||||
|
# try querying pkgsrc's help facility next
|
||||||
|
if [ -f ../../mk/bsd.pkg.mk ]; then
|
||||||
|
ans="$(make help topic="$i")"
|
||||||
|
if [ "$ans" != "No help found for $i." ]; then
|
||||||
|
echo "$i: $ans"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Give up!
|
||||||
|
echo "$PROGNAME: I don't know what \`$i' means!" 1>&2
|
||||||
|
rv=1
|
||||||
|
done
|
||||||
|
exit $rv
|
90
games/wtf/wtf.6
Normal file
90
games/wtf/wtf.6
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
.\" $NetBSD: wtf.6,v 1.19 2015/04/22 15:04:57 christos Exp $
|
||||||
|
.\"
|
||||||
|
.\" Public Domain
|
||||||
|
.\"
|
||||||
|
.Dd April 22, 2015
|
||||||
|
.Dt WTF 6
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm wtf
|
||||||
|
.Nd look up terms
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Fl f Ar dbfile
|
||||||
|
.Op Fl o
|
||||||
|
.Op Ar is
|
||||||
|
.Ar term ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility looks up the meaning of one or more
|
||||||
|
.Ar term
|
||||||
|
operands specified on the command line.
|
||||||
|
.Pp
|
||||||
|
.Ar term
|
||||||
|
will first be searched for as an acronym in the acronym databases,
|
||||||
|
which are expected to be in the format
|
||||||
|
.Dq acronym[tab]meaning .
|
||||||
|
If no match has been found,
|
||||||
|
.Nm
|
||||||
|
will check to see if the term is known by
|
||||||
|
.Xr whatis 1 ,
|
||||||
|
.Xr pkg_info 1 ,
|
||||||
|
or, when called from within a pkgsrc package directory,
|
||||||
|
pkgsrc's internal help facility,
|
||||||
|
.Dq make help topic=XXX .
|
||||||
|
.Pp
|
||||||
|
The optional
|
||||||
|
.Ar is
|
||||||
|
operand will be ignored, allowing the
|
||||||
|
fairly natural
|
||||||
|
.Dq wtf is WTF
|
||||||
|
usage.
|
||||||
|
.Pp
|
||||||
|
The following option is available:
|
||||||
|
.Bl -tag -width flag
|
||||||
|
.It Fl f Ar dbfile
|
||||||
|
Overrides the default list of acronym databases, bypassing the value of the
|
||||||
|
.Ev ACRONYMDB
|
||||||
|
variable.
|
||||||
|
Unlike this variable the
|
||||||
|
.Fl f
|
||||||
|
option only accepts one file name as an argument,
|
||||||
|
but it may be given multiple times to specify more than one file to use.
|
||||||
|
.It Fl o
|
||||||
|
Include acronyms that could be considered offensive to some.
|
||||||
|
Please consult
|
||||||
|
.Xr fortune 6
|
||||||
|
for more information about the
|
||||||
|
.Fl o
|
||||||
|
flag.
|
||||||
|
.El
|
||||||
|
.Sh ENVIRONMENT
|
||||||
|
.Bl -tag -width ACRONYMDB
|
||||||
|
.It Ev ACRONYMDB
|
||||||
|
The default list of acronym databases may be overridden by setting the
|
||||||
|
environment variable
|
||||||
|
.Ev ACRONYMDB
|
||||||
|
to the name of one or more space-separated file names of
|
||||||
|
acronym databases.
|
||||||
|
.El
|
||||||
|
.Sh FILES
|
||||||
|
.Bl -tag -width /usr/share/misc/acronyms.XXXX -compact
|
||||||
|
.It Pa /usr/share/misc/acronyms
|
||||||
|
default acronym database.
|
||||||
|
.It Pa /usr/share/misc/acronyms-o
|
||||||
|
default offensive acronym database.
|
||||||
|
.It Pa /usr/share/misc/acronyms.comp
|
||||||
|
default computer-related acronym database.
|
||||||
|
.El
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr make 1 ,
|
||||||
|
.Xr pkg_info 1 ,
|
||||||
|
.Xr whatis 1 ,
|
||||||
|
.Xr fortune 6
|
||||||
|
.Sh HISTORY
|
||||||
|
.Nm
|
||||||
|
first appeared in
|
||||||
|
.Nx 1.5 .
|
||||||
|
Initially it only translated acronyms;
|
||||||
|
functionality to look up the meaning of terms in other sources was added later.
|
Loading…
x
Reference in New Issue
Block a user