Newsgroups: comp.lang.misc,comp.lang.perl,comp.unix.shell,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!hookup!nic.hookup.net!xenitec!golem!davidf
From: davidf@golem.waterloo.on.ca (David J. Fiander)
Subject: Re: What language would you use?
Date: Fri, 11 Nov 1994 01:13:36 GMT
Message-ID: <1994Nov11.011336.23260@golem.waterloo.on.ca>
References: <39jf1i$aj3@csnews.cs.Colorado.EDU> <EJH.94Nov6185548@larry.gsfc.nasa.gov> <39p88i$3lv@larry.rice.edu>
Lines: 42
Xref: glinda.oz.cs.cmu.edu comp.lang.misc:19028 comp.lang.perl:38615 comp.unix.shell:21602 comp.lang.scheme:11157

I'm going to translate to Bourne shell, since it has useful
file I/O primitives. :-)

According to drichter@owlnet.rice.edu (David Richter):
>#this line should, but doesn't, work on the c.itohs
># setenv LOCALNAME $DISPLAY:ar
>#this line should work everywhere  (thanks to Robert Fullmer)
>setenv LOCALNAME `echo $DISPLAY | sed s/\\./\ /g | sed s/\:/\ /g |awk '{print $1}'`

	LOCALNAME=`expr "$DISPLAY" : '\([^.:]*\)'`

Or, if you don't grok expr

	LOCALNAME=`echo $DISPLAY | sed -e 's/[.:].*//'`

>
>set temp=`grep $LOCALNAME /usr/local/etc/terminals`
>setenv XTYPE `echo $temp | awk '{print $3}'`
>setenv ROOM  `echo $temp | awk '{print $2}'`
>if ( `echo $temp | awk '{print $4}'` == "Color" ) then
>	setenv COLOR TRUE
>else
>	setenv COLOR FALSE
>endif

	# Use awk, since a localname and a room could overlap
	awk "$1 == \"$LOCALNAME\"" /usr/local/etc/terminals |
		read foo ROOM XTYPE COLOR
	
	case $COLOR in
	Color)	COLOR=TRUE
		;;
	*)	COLOR=FALSE
		;;
	esac

	export ROOM XTYPE COLOR LOCALNAME

Hell you could do it simpler by running the line for the given
terminal into a csh array, for god's sake.

- David
