Don't try to make the same script portable between two completely different shells. Even compatibility of sh and bash is hard to achieve, and those use the same syntax... (I can't even imagine how one can stand csh in the first place.)
Write your settings scriptlet like this:
test "$?BASH_VERSION" = "0" || eval 'setenv() { export "$1=$2"; }'
setenv CATALINA_HOME "/mnt/apps/tomcat/6.0.20/linux"
setenv CATALINA_BASE "/home/app1/server"
I tested this in bash 4.2.20, tcsh 6.17 and dash 0.5.7.
Somewhat more sane solutions:
You could keep the settings as plain text, like this:
~/tomcat/catalina-home
/mnt/apps/tomcat/6.0.20/linux
your bash scripts
export CATALINA_HOME=$(< ~/tomcat/catalina-home)
export CATALINA_BASE=$(< ~/tomcat/catalina-base)
your csh scripts
setenv CATALINA_HOME "`cat ~/tomcat/catalina-home`"
setenv CATALINA_BASE "`cat ~/tomcat/catalina-base`"
You could write a wrapper that would set up the environment:
/usr/bin/tcat
#!/bin/sh
# you can use any, *any* language for this one
export CATALINA_HOME=/mnt/apps/tomcat/6.0.20/linux
export CATALINA_BASE=/home/app1/server
exec "$@"
if you had myscript, you'd run it like tcat myscript args args args
You could combine the above two approaches by setting up an "env directory" containing the raw data and running your script via Dan Bernstein's envdir or Gerrit Pape's chpst:
echo "/mnt/apps/tomcat/6.0.20/linux" > ~/tomcat-envdir/CATALINA_HOME
echo "/home/app1/server" > ~/tomcat-envdir/CATALINA_BASE
envdir ~/tomcat-envdir/ myscript
chpst -e ~/tomcat-envdir/ myscript