In article <1piwk1d.1qnfocmjw81h7N%
[email protected]>,
Hauke Fath <
[email protected]> wrote:
Hi,
what is the proper {t,}csh way to test if a variable is either unset, or >empty?
The naive
if ( ! ${?TERM} || ${TERM} == "" ) ...
errors out in the second expression, for obvious reasons. While tcsh
does do short circuit expressions, it attempts to expand variables >beforehand.
You have to do it step by step. For example, the following works for me:
if $?TERM then
if $TERM == "" then
echo "TERM is set but empty"
else
echo "TERM is set to: $TERM"
endif
else
echo "TERM is unset"
endif
ObHint: " | sed '/csh.*harmful/d'"
Well done!
But, yeah, the syntax of csh/tcsh is kinda creaky, but that's mainly because
it hasn't been maintained (i.e., enhanced, built up, etc) in decades. It pretty much is what it was in the 1980s. But the fact is, if you use tcsh
as your interactive shell, as I still do, you still need to be able to edit your startup files and stuff. So, you still need to keeping de old skills alive!
--
In politics and in life, ignorance is not a virtue.
-- Barack Obama --
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)