Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-20-2014, 03:42 PM   #1
Registered: Oct 2002
Posts: 496

Rep: Reputation: 62
Test if environment variable is set in tcsh

Test variable is MYSETUP.

This is how I am trying to check it.


if ( $?MYSETUP ) then
	echo "IS SET"
	echo "NOT SET"
If the variable is not set instead of returning "NOT SET" it returns "MYSETUP: Undefined variable.".

With the variable set it echos the value and returns "IS SET".

Looks like the shell is doing something with the conditional besides just testing for TRUE or FALSE.

This should be trivial but I can't get it to work.

tcsh version is 6.14.00 but I have no root privileges so that can not be changed.

I'm open to suggestions and thanks in advance.
Old 01-20-2014, 04:08 PM   #2
Registered: Oct 2002
Posts: 496

Original Poster
Rep: Reputation: 62
I'm sure I'm not stupid but that does not prevent me from occasionally doing stupid things. I had an echo statement in my ~/.tcshrc that was causing the confusion.

The above code does work.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Environment variable being set twice Mechanic Slackware 12 08-03-2010 04:22 AM
Set environment variable prabuinet Linux - Newbie 2 12-07-2008 01:44 AM
tcsh set/read variable command? johnpaulodonnell Linux - Newbie 2 08-22-2007 10:26 AM
How to set an environment variable royeo Linux - Newbie 1 12-01-2006 01:59 AM
how to set environment variable pranith Linux - Newbie 1 01-28-2005 12:23 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration