xref: /dragonfly/games/ching/ching/ching.sh (revision e95199c5)
1#!/bin/sh
2#
3#	$NetBSD: ching.sh,v 1.1 2005/06/30 13:30:33 perry Exp $
4#
5# Copyright (c) Caldera International Inc. 2001-2002. All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# 1. Redistributions of source code and documentation must retain the
12#    above copyright notice, this list of conditions and the following
13#    disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17# 3. All advertising materials mentioning features or use of this software
18#    must display the following acknowledgement:
19# 	This product includes software developed or owned by Caldera
20# 	International, Inc.
21# 4. Neither the name of Caldera International, Inc. nor the names of
22#    other contributors may be used to endorse or promote products
23#    derived from this software without specific prior written permission.
24#
25# USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
26# INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
27# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29# DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
30# FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
31# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
33# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
35# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
36# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37#
38#
39# Copyright (c) 1993
40#	The Regents of the University of California.  All rights reserved.
41#
42# Redistribution and use in source and binary forms, with or without
43# modification, are permitted provided that the following conditions
44# are met:
45# 1. Redistributions of source code must retain the above copyright
46#    notice, this list of conditions and the following disclaimer.
47# 2. Redistributions in binary form must reproduce the above copyright
48#    notice, this list of conditions and the following disclaimer in the
49#    documentation and/or other materials provided with the distribution.
50# 3. Neither the name of the University nor the names of its contributors
51#    may be used to endorse or promote products derived from this software
52#    without specific prior written permission.
53#
54# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64# SUCH DAMAGE.
65#
66#	@(#)ching.sh	8.1 (Berkeley) 5/31/93
67#
68
69SHARE=/usr/share/games/ching
70PROGS=/usr/libexec/ching
71
72format()
73{
74	if command -v nroff >/dev/null 2>&1 ; then
75		# Prefer nroff(1); require the 'groff' package.
76		nroff -
77	else
78		# Adjust mandoc(1)'s output to mimic nroff(1)'s.
79		mandoc -Wunsupp | sed '1,3d;$d;s/^/\t/'
80	fi
81}
82
83case $1 in
84	[6-9]*)	HEXAGRAM=$1; shift;;
85esac
86
87if [ -z "$HEXAGRAM" ]; then
88	HEXAGRAM=$($PROGS/castching)
89	echo
90fi
91
92{ cat $SHARE/macros; $PROGS/printching $HEXAGRAM; } | format | ${PAGER-more}
93