#!/usr/bin/perl
#
#DESCRIPTION
#  This file reads from one or more files that contain lines like:  
#    foo=bar
#    quz=some value
#  The output is a series of t/csh setenv commands to do the same
#  thing. This lets you load such files into your environment list.
#
#AUTHOR
#  John Chambers <jc@trillian.mit.edu>

$! = 1;
($me = $0) =~ s"^.*/"";
$style = 0;
if ($me =~ /^(.*)env$/) {$sh = $1}
if    ($sh =~ /^[tc]+sh$/)  {$style = 2}
elsif ($sh =~ /^[bak]*sh$/) {$style = 1}
for $line (<>) {
	chomp $line;
	if (($var,$val) = ($line =~ /^(\w+)\s*=\s*(.*)$/)) {
		if    ($style == 2) {print "setenv $var '$val';\n"}
		elsif ($style == 1) {print "$var='$val'; export $var\n"} 
		else                {print "setenv $var '$val';\n"}
	}
}
