cshtcsh

What is the csh/tcsh equivalent of set -u in bash?


csh/tcsh by default exits with error on undefined variables. I want to suppress that behavior for a piece of code just like bash does with set +u. Is there a way to do that?


Solution

  • No, there is no setting for this.

    The best you can do is check if the variable exists with $?varname:

    if ( $?undefined ) then
        echo "$undefined"
    endif
    

    Or use if ( ! $?undefined ) to inverse the check.