LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-20-2014, 02:42 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 488

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


Test variable is MYSETUP.

This is how I am trying to check it.

Code:
#!/bin/tcsh

if ( $?MYSETUP ) then
	echo "IS SET"
else
	echo "NOT SET"
endif
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, 03:08 PM   #2
sharky
Member
 
Registered: Oct 2002
Posts: 488

Original Poster
Rep: Reputation: 54
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.
 
  


Reply


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 03:22 AM
Set environment variable prabuinet Linux - Newbie 2 12-07-2008 12:44 AM
tcsh set/read variable command? johnpaulodonnell Linux - Newbie 2 08-22-2007 09:26 AM
How to set an environment variable royeo Linux - Newbie 1 12-01-2006 12:59 AM
how to set environment variable pranith Linux - Newbie 1 01-27-2005 11:23 PM


All times are GMT -5. The time now is 11:51 AM.

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