> You should check for $ENV{SHELL} and emit "setenv VAR VALUE"
> lines if appropriate.
$ENV{SHELL} is not a way to determine your current shell. $ENV{SHELL} is your »preferred shell« (aka login shell in /etc/passwd), see The Single UNIX Specification, Version 3.
Example:
# we are in bash, all is fine
$ eval `perl -le 'print $ENV{SHELL} =~ /csh/ ? "setenv FOO bar" : "exp
+ort FOO=bar"'`
# now we switch to tcsh
$ tcsh
$ eval `perl -le 'print $ENV{SHELL} =~ /csh/ ? "setenv FOO bar" : "exp
+ort FOO=bar"'`
$ export: Command not found.
$ echo $SHELL
/bin/bash
It seems that there is no portable way to find out the name of your current shell. We discussed that some time ago at de.comp.os.unix.shell.