danny
danny

Reputation: 1299

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?

Upvotes: 0

Views: 192

Answers (1)

Martin Tournoij
Martin Tournoij

Reputation: 27822

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.

Upvotes: 1

Related Questions