Telling csh about multiple, machine-dependent libraries
Chris Torek
chris at mimsy.UUCP
Fri Nov 18 04:42:39 AEST 1988
[`heart-of-gold' is not in the UUCP maps, and linus claims never to have
heard of the machine, although the news path is linus!heart-of-gold!jc;
what goes on here?]
In article <173 at heart-of-gold> jc at heart-of-gold (John M Chambers) writes:
>| set mtype = bin
>| if (`sun2`) set mtype = sun2
>| if (`sun3`) set mtype = sun3
>| if (`sun4`) set mtype = sun4
>| set path=(. ~/{$mtype,sh,csh,awk} /bin /usr/{ucb,etc,local,local/{$mtype,sh},bin,lib,dos,hosts,games,demo,NeWS/{bin,demo}} /etc)
The proper syntax is
if ( { program } ) ...
The {} pair will substitute for the () pair, so you can write
if { program } ...
or in this case
if { sun2 } set mtype = sun2
if { sun3 } set mtype = sun3
if { sun4 } set mtype = sun4
>... I've tried a few other variants, includeing such things as
> sun3 && set mtype = sun3
This should work. If you have the `machine' command (and it does
the right thing) you can also use
switch (`machine`)
case sun2:
set mtype = sun2
breaksw
case sun3:
set mtype = sun3
breaksw
case sun4:
set mtype = sun4
breaksw
default:
echo "unknown machine type `machine`"
breaksw
endsw
or (much simpler)
set mtype = `machine`
>For that matter, the above code, if taken to a machine that lacks, e.g.,
>a `sun4` command, bombs out and fails to read the rest of .cshrc, so this
>is obviously not a general approach.
This is one reason `machine` is preferable if available. csh does not
have a convenient way to test the existence of a program; but you can
always use a Bourne shell script instead:
set mtype = `sh .get-machine`
where `.get-machine' reads
if (set -e; machine) >/dev/null 2>&1; then
machine
else
echo "no \`\`machine'' command; assuming \`\`bin''" 1>&2
echo bin
fi
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list