0

I would like to have a script to add /path/to/hoge in CLASSPATH by csh.

setenv CLASSPATH ${CLASSPATH}:/path/to/hoge

However, it returns an error, that says, No match error.

It is beause CLASSPATH was unset.

How can I deal with the possibility where CLASSPATH is not set?

kensuke1984
  • 949
  • 1
  • 11
  • 21
  • Related: [How can I check if a variable is empty or not in tcsh Shell](http://stackoverflow.com/questions/22640093/how-can-i-check-if-a-variable-is-empty-or-not-in-tcsh-shell). – Mark Plotnick Jul 13 '16 at 14:44

1 Answers1

1

This looks simple, using Mark's ref.:

if ( "${CLASSPATH}" == "" ) then
    setenv CLASSPATH /path/to/hoge
else 
    setenv CLASSPATH ${CLASSPATH}:/path/to/hoge
endif
J. Chomel
  • 8,193
  • 15
  • 41
  • 69