xref: /illumos-gate/usr/src/contrib/ast/src/cmd/INIT/iffe.sh (revision b30d1939)
1*b30d1939SAndy Fiddaman########################################################################
2*b30d1939SAndy Fiddaman#                                                                      #
3*b30d1939SAndy Fiddaman#               This software is part of the ast package               #
4*b30d1939SAndy Fiddaman#          Copyright (c) 1994-2012 AT&T Intellectual Property          #
5*b30d1939SAndy Fiddaman#                      and is licensed under the                       #
6*b30d1939SAndy Fiddaman#                 Eclipse Public License, Version 1.0                  #
7*b30d1939SAndy Fiddaman#                    by AT&T Intellectual Property                     #
8*b30d1939SAndy Fiddaman#                                                                      #
9*b30d1939SAndy Fiddaman#                A copy of the License is available at                 #
10*b30d1939SAndy Fiddaman#          http://www.eclipse.org/org/documents/epl-v10.html           #
11*b30d1939SAndy Fiddaman#         (with md5 checksum b35adb5213ca9657e911e9befb180842)         #
12*b30d1939SAndy Fiddaman#                                                                      #
13*b30d1939SAndy Fiddaman#              Information and Software Systems Research               #
14*b30d1939SAndy Fiddaman#                            AT&T Research                             #
15*b30d1939SAndy Fiddaman#                           Florham Park NJ                            #
16*b30d1939SAndy Fiddaman#                                                                      #
17*b30d1939SAndy Fiddaman#                 Glenn Fowler <gsf@research.att.com>                  #
18*b30d1939SAndy Fiddaman#                                                                      #
19*b30d1939SAndy Fiddaman########################################################################
20*b30d1939SAndy Fiddaman# Glenn Fowler & Phong Vo
21*b30d1939SAndy Fiddaman# AT&T Research
22*b30d1939SAndy Fiddaman#
23*b30d1939SAndy Fiddaman# test if feature exists
24*b30d1939SAndy Fiddaman# this script is written to make it through all sh variants
25*b30d1939SAndy Fiddaman#
26*b30d1939SAndy Fiddaman# NOTE: .exe a.out suffix and [\\/] in path patterns for dos/nt
27*b30d1939SAndy Fiddaman
28*b30d1939SAndy Fiddamancase $-:$BASH_VERSION in
29*b30d1939SAndy Fiddaman*x*:[0123456789]*)	: bash set -x is broken :; set +ex ;;
30*b30d1939SAndy Fiddamanesac
31*b30d1939SAndy Fiddaman
32*b30d1939SAndy Fiddamancommand=iffe
33*b30d1939SAndy Fiddamanversion=2012-07-17 # update in USAGE too #
34*b30d1939SAndy Fiddaman
35*b30d1939SAndy Fiddamancompile() # $cc ...
36*b30d1939SAndy Fiddaman{
37*b30d1939SAndy Fiddaman	"$@" 2>$tmp.err
38*b30d1939SAndy Fiddaman	_compile_status=$?
39*b30d1939SAndy Fiddaman	if	test -s $tmp.err
40*b30d1939SAndy Fiddaman	then	cat $tmp.err >&2
41*b30d1939SAndy Fiddaman		case $_compile_status in
42*b30d1939SAndy Fiddaman		[1-9]|[1-9][0-9]|1[01][0-9]|12[0-7])
43*b30d1939SAndy Fiddaman			if	egrep -i -c 'terminated with signal|core dump|segmentation fault' $tmp.err >&$nullout
44*b30d1939SAndy Fiddaman			then	_compile_status=139
45*b30d1939SAndy Fiddaman			fi
46*b30d1939SAndy Fiddaman			;;
47*b30d1939SAndy Fiddaman		esac
48*b30d1939SAndy Fiddaman	fi
49*b30d1939SAndy Fiddaman	case $_compile_status in
50*b30d1939SAndy Fiddaman	?|??|1[01]?|12[0-8]|25?)
51*b30d1939SAndy Fiddaman		;;
52*b30d1939SAndy Fiddaman	*)	echo "$command: $@" >&$stderr
53*b30d1939SAndy Fiddaman		cat $tmp.err >&$stderr
54*b30d1939SAndy Fiddaman		echo "$command: $1: core dump or fatal interruption -- results inconclusive" >&$stderr
55*b30d1939SAndy Fiddaman		exit $_compile_status
56*b30d1939SAndy Fiddaman		;;
57*b30d1939SAndy Fiddaman	esac
58*b30d1939SAndy Fiddaman	return $_compile_status
59*b30d1939SAndy Fiddaman}
60*b30d1939SAndy Fiddaman
61*b30d1939SAndy Fiddamanis_hdr() # [ - ] [ file.c ] hdr
62*b30d1939SAndy Fiddaman{
63*b30d1939SAndy Fiddaman	case $1 in
64*b30d1939SAndy Fiddaman	-)	_is_hdr_flag=-; shift ;;
65*b30d1939SAndy Fiddaman	*)	_is_hdr_flag= ;;
66*b30d1939SAndy Fiddaman	esac
67*b30d1939SAndy Fiddaman	case $1 in
68*b30d1939SAndy Fiddaman	*.c)	_is_hdr_file=$1; shift ;;
69*b30d1939SAndy Fiddaman	*)	_is_hdr_file=$tmp.c ;;
70*b30d1939SAndy Fiddaman	esac
71*b30d1939SAndy Fiddaman	is hdr $1
72*b30d1939SAndy Fiddaman	compile $cc -c $_is_hdr_file <&$nullin >&$nullout 2>$tmp.e
73*b30d1939SAndy Fiddaman	_is_hdr_status=$?
74*b30d1939SAndy Fiddaman	case $_is_hdr_status in
75*b30d1939SAndy Fiddaman	0)	if	test -s $tmp.e
76*b30d1939SAndy Fiddaman		then	case `grep '#.*error' $tmp.e` in
77*b30d1939SAndy Fiddaman			?*)	_is_hdr_status=1 ;;
78*b30d1939SAndy Fiddaman			esac
79*b30d1939SAndy Fiddaman		fi
80*b30d1939SAndy Fiddaman		;;
81*b30d1939SAndy Fiddaman	esac
82*b30d1939SAndy Fiddaman	case $_is_hdr_status in
83*b30d1939SAndy Fiddaman	0)	success $_is_hdr_flag
84*b30d1939SAndy Fiddaman		;;
85*b30d1939SAndy Fiddaman	*)	case $debug in
86*b30d1939SAndy Fiddaman		3)	cat $tmp.e >&$stderr ;;
87*b30d1939SAndy Fiddaman		esac
88*b30d1939SAndy Fiddaman		failure $_is_hdr_flag
89*b30d1939SAndy Fiddaman		;;
90*b30d1939SAndy Fiddaman	esac
91*b30d1939SAndy Fiddaman	return $_is_hdr_status
92*b30d1939SAndy Fiddaman}
93*b30d1939SAndy Fiddaman
94*b30d1939SAndy Fiddamanpkg() # package
95*b30d1939SAndy Fiddaman{
96*b30d1939SAndy Fiddaman	case $1 in
97*b30d1939SAndy Fiddaman	'')	pth=''
98*b30d1939SAndy Fiddaman		case $pth in
99*b30d1939SAndy Fiddaman		'')	pth="/bin /usr/bin" ;;
100*b30d1939SAndy Fiddaman		*:*)	pth=`echo "$pth" | sed 's/:/ /g'` ;;
101*b30d1939SAndy Fiddaman		esac
102*b30d1939SAndy Fiddaman		return
103*b30d1939SAndy Fiddaman		;;
104*b30d1939SAndy Fiddaman	'<')	shift
105*b30d1939SAndy Fiddaman		;;
106*b30d1939SAndy Fiddaman	*)	return
107*b30d1939SAndy Fiddaman		;;
108*b30d1939SAndy Fiddaman	esac
109*b30d1939SAndy Fiddaman	case $1 in
110*b30d1939SAndy Fiddaman	X|X11*)	i="openwin"
111*b30d1939SAndy Fiddaman		case $1 in
112*b30d1939SAndy Fiddaman		X)	set X11 ;;
113*b30d1939SAndy Fiddaman		esac
114*b30d1939SAndy Fiddaman		case $1 in
115*b30d1939SAndy Fiddaman		X11)	case $# in
116*b30d1939SAndy Fiddaman			1)	set $1 6 5 4 ;;
117*b30d1939SAndy Fiddaman			esac
118*b30d1939SAndy Fiddaman			;;
119*b30d1939SAndy Fiddaman		esac
120*b30d1939SAndy Fiddaman		;;
121*b30d1939SAndy Fiddaman	*)	i=
122*b30d1939SAndy Fiddaman		;;
123*b30d1939SAndy Fiddaman	esac
124*b30d1939SAndy Fiddaman	pth="{ usr . - . contrib local $i - . share - . lib - $1"
125*b30d1939SAndy Fiddaman	i=$1
126*b30d1939SAndy Fiddaman	while	:
127*b30d1939SAndy Fiddaman	do	shift
128*b30d1939SAndy Fiddaman		case $# in
129*b30d1939SAndy Fiddaman		0)	break ;;
130*b30d1939SAndy Fiddaman		esac
131*b30d1939SAndy Fiddaman		case $1 in
132*b30d1939SAndy Fiddaman		'>')	shift; break ;;
133*b30d1939SAndy Fiddaman		esac
134*b30d1939SAndy Fiddaman		pth="$pth ${i}R$1 ${i}.$1"
135*b30d1939SAndy Fiddaman	done
136*b30d1939SAndy Fiddaman	pth="$pth . } $*"
137*b30d1939SAndy Fiddaman}
138*b30d1939SAndy Fiddaman
139*b30d1939SAndy Fiddamanis() # op name
140*b30d1939SAndy Fiddaman{
141*b30d1939SAndy Fiddaman	case $verbose in
142*b30d1939SAndy Fiddaman	1)	case $complete in
143*b30d1939SAndy Fiddaman		1)	failure ;;
144*b30d1939SAndy Fiddaman		esac
145*b30d1939SAndy Fiddaman		oo=$1
146*b30d1939SAndy Fiddaman		shift
147*b30d1939SAndy Fiddaman		case $1 in
148*b30d1939SAndy Fiddaman		?*)	yy=is
149*b30d1939SAndy Fiddaman			ii=$1
150*b30d1939SAndy Fiddaman			complete=1
151*b30d1939SAndy Fiddaman			case $oo in
152*b30d1939SAndy Fiddaman			cmd)	mm="a command" ;;
153*b30d1939SAndy Fiddaman			dat)	mm="a library data symbol" ;;
154*b30d1939SAndy Fiddaman			dfn)	mm="a macro with extractable value" ;;
155*b30d1939SAndy Fiddaman			exp)	mm="true" ;;
156*b30d1939SAndy Fiddaman			hdr)	mm="a header" ;;
157*b30d1939SAndy Fiddaman			id)	mm="an identifier" ;;
158*b30d1939SAndy Fiddaman			lcl)	mm="a native header" ;;
159*b30d1939SAndy Fiddaman			key)	mm="a reserved keyword" ;;
160*b30d1939SAndy Fiddaman			lib)	mm="a library function" ;;
161*b30d1939SAndy Fiddaman			LIB)	case $2 in
162*b30d1939SAndy Fiddaman				"")	mm="a library" ;;
163*b30d1939SAndy Fiddaman				*)	ii=$*; mm="a library group" ;;
164*b30d1939SAndy Fiddaman				esac
165*b30d1939SAndy Fiddaman				;;
166*b30d1939SAndy Fiddaman			mac)	mm="a macro" ;;
167*b30d1939SAndy Fiddaman			mem)	mm="a member of $2" ;;
168*b30d1939SAndy Fiddaman			mth)	mm="a math library symbol" ;;
169*b30d1939SAndy Fiddaman			nos)	mm="a non-opaque struct" ;;
170*b30d1939SAndy Fiddaman			npt)	mm="a symbol that needs a prototype" ;;
171*b30d1939SAndy Fiddaman			num)	mm="a numeric constant or enum" ;;
172*b30d1939SAndy Fiddaman			nxt)	mm="an include path for the native header" ;;
173*b30d1939SAndy Fiddaman			opt)	mm="set in \$PACKAGE_OPTIONS" ;;
174*b30d1939SAndy Fiddaman			pth)	mm="a file" ;;
175*b30d1939SAndy Fiddaman			run)	yy="capture output of" mm= ;;
176*b30d1939SAndy Fiddaman			siz)	mm="a type with known size" ;;
177*b30d1939SAndy Fiddaman			sym)	mm="a typed variable" ;;
178*b30d1939SAndy Fiddaman			sys)	mm="a system header" ;;
179*b30d1939SAndy Fiddaman			typ)	mm="a type or typedef" ;;
180*b30d1939SAndy Fiddaman			val)	yy="determine" mm="value" ;;
181*b30d1939SAndy Fiddaman			*)	yy= mm= ;;
182*b30d1939SAndy Fiddaman			esac
183*b30d1939SAndy Fiddaman			case $ii in
184*b30d1939SAndy Fiddaman			[abcdefghijklmnopqrstuvwxyz]*[abcdefghijklmnopqrstuvwxyz]'{') ii="$ii ... }end" ;;
185*b30d1939SAndy Fiddaman			esac
186*b30d1939SAndy Fiddaman			$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
187*b30d1939SAndy Fiddaman			complete=1
188*b30d1939SAndy Fiddaman			;;
189*b30d1939SAndy Fiddaman		esac
190*b30d1939SAndy Fiddaman		;;
191*b30d1939SAndy Fiddaman	esac
192*b30d1939SAndy Fiddaman}
193*b30d1939SAndy Fiddaman
194*b30d1939SAndy Fiddamansuccess()
195*b30d1939SAndy Fiddaman{
196*b30d1939SAndy Fiddaman	case $1 in
197*b30d1939SAndy Fiddaman	-)	shift
198*b30d1939SAndy Fiddaman		;;
199*b30d1939SAndy Fiddaman	*)	case $result in
200*b30d1939SAndy Fiddaman		UNKNOWN)	result=SUCCESS ;;
201*b30d1939SAndy Fiddaman		esac
202*b30d1939SAndy Fiddaman		case $1 in
203*b30d1939SAndy Fiddaman		+)	return ;;
204*b30d1939SAndy Fiddaman		esac
205*b30d1939SAndy Fiddaman		;;
206*b30d1939SAndy Fiddaman	esac
207*b30d1939SAndy Fiddaman	case $complete:$verbose in
208*b30d1939SAndy Fiddaman	1:1)	case $suspended in
209*b30d1939SAndy Fiddaman		1)	suspended=0
210*b30d1939SAndy Fiddaman			$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
211*b30d1939SAndy Fiddaman			;;
212*b30d1939SAndy Fiddaman		esac
213*b30d1939SAndy Fiddaman		complete=0
214*b30d1939SAndy Fiddaman		case $# in
215*b30d1939SAndy Fiddaman		0)	mm="yes" ;;
216*b30d1939SAndy Fiddaman		*)	mm="'$*'" ;;
217*b30d1939SAndy Fiddaman		esac
218*b30d1939SAndy Fiddaman		case $debug in
219*b30d1939SAndy Fiddaman		0)	echo " $mm" >&$stderr ;;
220*b30d1939SAndy Fiddaman		*)	echo "$command: ... $mm" >&$stderr ;;
221*b30d1939SAndy Fiddaman		esac
222*b30d1939SAndy Fiddaman		;;
223*b30d1939SAndy Fiddaman	esac
224*b30d1939SAndy Fiddaman}
225*b30d1939SAndy Fiddaman
226*b30d1939SAndy Fiddamanfailure()
227*b30d1939SAndy Fiddaman{
228*b30d1939SAndy Fiddaman	case $1 in
229*b30d1939SAndy Fiddaman	-)	shift ;;
230*b30d1939SAndy Fiddaman	*)	result=FAILURE
231*b30d1939SAndy Fiddaman		case $1 in
232*b30d1939SAndy Fiddaman		+)	return ;;
233*b30d1939SAndy Fiddaman		esac
234*b30d1939SAndy Fiddaman		;;
235*b30d1939SAndy Fiddaman	esac
236*b30d1939SAndy Fiddaman	case $complete:$verbose in
237*b30d1939SAndy Fiddaman	1:1)	case $suspended in
238*b30d1939SAndy Fiddaman		1)	suspended=0
239*b30d1939SAndy Fiddaman			$show "$command: test:" $yy $ii $mm "...$SHOW" >&$stderr
240*b30d1939SAndy Fiddaman			;;
241*b30d1939SAndy Fiddaman		esac
242*b30d1939SAndy Fiddaman		complete=0
243*b30d1939SAndy Fiddaman		case $group in
244*b30d1939SAndy Fiddaman		'')	case $# in
245*b30d1939SAndy Fiddaman			0)	mm="no" ;;
246*b30d1939SAndy Fiddaman			*)	mm=$* ;;
247*b30d1939SAndy Fiddaman			esac
248*b30d1939SAndy Fiddaman			;;
249*b30d1939SAndy Fiddaman		*)	mm=
250*b30d1939SAndy Fiddaman			;;
251*b30d1939SAndy Fiddaman		esac
252*b30d1939SAndy Fiddaman		case $debug in
253*b30d1939SAndy Fiddaman		0)	echo " $mm" >&$stderr ;;
254*b30d1939SAndy Fiddaman		*)	echo "$command: ... $mm" >&$stderr ;;
255*b30d1939SAndy Fiddaman		esac
256*b30d1939SAndy Fiddaman		;;
257*b30d1939SAndy Fiddaman	esac
258*b30d1939SAndy Fiddaman}
259*b30d1939SAndy Fiddaman
260*b30d1939SAndy Fiddaman# report
261*b30d1939SAndy Fiddaman#
262*b30d1939SAndy Fiddaman#	-	ignore global status
263*b30d1939SAndy Fiddaman#	-0	normal sense
264*b30d1939SAndy Fiddaman#	-1	inverted sense if ! def
265*b30d1939SAndy Fiddaman#	status	test status 0:success *:failure
266*b30d1939SAndy Fiddaman#	success	success comment
267*b30d1939SAndy Fiddaman#	failure	failure comment
268*b30d1939SAndy Fiddaman#	default	default setting comment
269*b30d1939SAndy Fiddaman#
270*b30d1939SAndy Fiddaman#   globals
271*b30d1939SAndy Fiddaman#
272*b30d1939SAndy Fiddaman#	$not	invert test sense
273*b30d1939SAndy Fiddaman# 	$M	test variable
274*b30d1939SAndy Fiddaman#	$m	test macro
275*b30d1939SAndy Fiddaman#	$v	default macro
276*b30d1939SAndy Fiddaman
277*b30d1939SAndy Fiddamanreport() # [-] [-0] [-1] status value success failure default
278*b30d1939SAndy Fiddaman{
279*b30d1939SAndy Fiddaman	case $1 in
280*b30d1939SAndy Fiddaman	-)	_report_ignore=$1
281*b30d1939SAndy Fiddaman		shift
282*b30d1939SAndy Fiddaman		;;
283*b30d1939SAndy Fiddaman	*)	_report_ignore=
284*b30d1939SAndy Fiddaman		;;
285*b30d1939SAndy Fiddaman	esac
286*b30d1939SAndy Fiddaman	_report_not=$not
287*b30d1939SAndy Fiddaman	case $1 in
288*b30d1939SAndy Fiddaman	-0)	shift
289*b30d1939SAndy Fiddaman		;;
290*b30d1939SAndy Fiddaman	-1)	shift
291*b30d1939SAndy Fiddaman		case $def in
292*b30d1939SAndy Fiddaman		''|-)	case $_report_not in
293*b30d1939SAndy Fiddaman			1)	_report_not= ;;
294*b30d1939SAndy Fiddaman			*)	_report_not=1 ;;
295*b30d1939SAndy Fiddaman			esac
296*b30d1939SAndy Fiddaman			;;
297*b30d1939SAndy Fiddaman		esac
298*b30d1939SAndy Fiddaman		;;
299*b30d1939SAndy Fiddaman	esac
300*b30d1939SAndy Fiddaman	_report_status=$1
301*b30d1939SAndy Fiddaman	case $_report_ignore:$_report_status in
302*b30d1939SAndy Fiddaman	-:*)	;;
303*b30d1939SAndy Fiddaman	*:0)	success $_report_ignore
304*b30d1939SAndy Fiddaman		;;
305*b30d1939SAndy Fiddaman	*)	failure $_report_ignore
306*b30d1939SAndy Fiddaman		case $group in
307*b30d1939SAndy Fiddaman		?*)	return ;;
308*b30d1939SAndy Fiddaman		esac
309*b30d1939SAndy Fiddaman		;;
310*b30d1939SAndy Fiddaman	esac
311*b30d1939SAndy Fiddaman	_report_value=$2
312*b30d1939SAndy Fiddaman	case $_report_not in
313*b30d1939SAndy Fiddaman	1)	case $_report_status in
314*b30d1939SAndy Fiddaman		0)	_report_status=1 ;;
315*b30d1939SAndy Fiddaman		*)	_report_status=0 ;;
316*b30d1939SAndy Fiddaman		esac
317*b30d1939SAndy Fiddaman		_report_success=$4
318*b30d1939SAndy Fiddaman		_report_failure=$3
319*b30d1939SAndy Fiddaman		;;
320*b30d1939SAndy Fiddaman	*)	_report_success=$3
321*b30d1939SAndy Fiddaman		_report_failure=$4
322*b30d1939SAndy Fiddaman		;;
323*b30d1939SAndy Fiddaman	esac
324*b30d1939SAndy Fiddaman	_report_default=$5
325*b30d1939SAndy Fiddaman	case $_report_status in
326*b30d1939SAndy Fiddaman	0)	case $M in
327*b30d1939SAndy Fiddaman		*-*)	;;
328*b30d1939SAndy Fiddaman		*)	usr="$usr$nl#define $m $_report_value"
329*b30d1939SAndy Fiddaman			case $_report_success in
330*b30d1939SAndy Fiddaman			''|-)	;;
331*b30d1939SAndy Fiddaman			*)	case $define in
332*b30d1939SAndy Fiddaman				1)	echo "#define $m	$_report_value	/* $_report_success */" ;;
333*b30d1939SAndy Fiddaman				n)	echo "$m=$_report_value"
334*b30d1939SAndy Fiddaman				esac
335*b30d1939SAndy Fiddaman				;;
336*b30d1939SAndy Fiddaman			esac
337*b30d1939SAndy Fiddaman			eval $m=\'$_report_value\'
338*b30d1939SAndy Fiddaman			;;
339*b30d1939SAndy Fiddaman		esac
340*b30d1939SAndy Fiddaman		;;
341*b30d1939SAndy Fiddaman	*)	case $M in
342*b30d1939SAndy Fiddaman		*-*)	;;
343*b30d1939SAndy Fiddaman		*)	case $_report_failure in
344*b30d1939SAndy Fiddaman			''|-)	;;
345*b30d1939SAndy Fiddaman			*)	case $define$all$config$undef in
346*b30d1939SAndy Fiddaman				1?1?|1??1)echo "#undef	$m		/* $_report_failure */" ;;
347*b30d1939SAndy Fiddaman				11??)	  echo "#define $m	0	/* $_report_failure */" ;;
348*b30d1939SAndy Fiddaman				n1?1)	  echo "$m=" ;;
349*b30d1939SAndy Fiddaman				n1??)	  echo "$m=0" ;;
350*b30d1939SAndy Fiddaman				esac
351*b30d1939SAndy Fiddaman				;;
352*b30d1939SAndy Fiddaman			esac
353*b30d1939SAndy Fiddaman			case $_report_default in
354*b30d1939SAndy Fiddaman			''|-)	;;
355*b30d1939SAndy Fiddaman			*)	case $define$set in
356*b30d1939SAndy Fiddaman				1?*)	echo "#define $v	$set	/* $_report_default */" ;;
357*b30d1939SAndy Fiddaman				n?*)	echo "$v=$set" ;;
358*b30d1939SAndy Fiddaman				esac
359*b30d1939SAndy Fiddaman				;;
360*b30d1939SAndy Fiddaman			esac
361*b30d1939SAndy Fiddaman			eval $m=0
362*b30d1939SAndy Fiddaman			;;
363*b30d1939SAndy Fiddaman		esac
364*b30d1939SAndy Fiddaman		;;
365*b30d1939SAndy Fiddaman	esac
366*b30d1939SAndy Fiddaman}
367*b30d1939SAndy Fiddaman
368*b30d1939SAndy Fiddamannoisy()
369*b30d1939SAndy Fiddaman{
370*b30d1939SAndy Fiddaman	case $complete:$verbose in
371*b30d1939SAndy Fiddaman	1:1)	suspended=1
372*b30d1939SAndy Fiddaman		echo >&$stderr
373*b30d1939SAndy Fiddaman		;;
374*b30d1939SAndy Fiddaman	esac
375*b30d1939SAndy Fiddaman}
376*b30d1939SAndy Fiddaman
377*b30d1939SAndy Fiddamanhere_broken=0
378*b30d1939SAndy Fiddaman
379*b30d1939SAndy Fiddamanliteral() # line that echo might process
380*b30d1939SAndy Fiddaman{
381*b30d1939SAndy Fiddaman	if	cat <<!
382*b30d1939SAndy Fiddaman$*
383*b30d1939SAndy Fiddaman!
384*b30d1939SAndy Fiddaman	then	: old here doc botch not present
385*b30d1939SAndy Fiddaman	else	case $here_broken in
386*b30d1939SAndy Fiddaman		0)	here_broken=1
387*b30d1939SAndy Fiddaman			echo "$command: your shell botches here documents; this was fixed back in the 80's" >&$stderr
388*b30d1939SAndy Fiddaman			;;
389*b30d1939SAndy Fiddaman		esac
390*b30d1939SAndy Fiddaman		sh -c "cat <<!
391*b30d1939SAndy Fiddaman$*
392*b30d1939SAndy Fiddaman!
393*b30d1939SAndy Fiddaman"
394*b30d1939SAndy Fiddaman	fi
395*b30d1939SAndy Fiddaman}
396*b30d1939SAndy Fiddaman
397*b30d1939SAndy Fiddamancopy() # "output-file" "data-that-must-not-be-processed-by-echo"
398*b30d1939SAndy Fiddaman{
399*b30d1939SAndy Fiddaman	case $1 in
400*b30d1939SAndy Fiddaman	-)	case $shell in
401*b30d1939SAndy Fiddaman		ksh)	print -r - "$2"
402*b30d1939SAndy Fiddaman			;;
403*b30d1939SAndy Fiddaman		*)	if	cat <<!
404