• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

csh scripting question

CTho9305

Elite Member
What is the case where this works:

if ("x$x" == "xyes') then
...
endif

but this just produces a syntax error?

if ($x == "yes") then
...
endif

I know I've run into the second one breaking before, when x is blank or a newline or something like that... but I can't reproduce it. The cases where I ran into it were in a complex maze of nested csh scripts; I haven't had much luck creating a small example to show the danger of the second form.
 
Code:
if ("x$x" == "xyes') then
Did you type that correctly?

That single quote (at the end) doesn't look right...

If that was NOT a typo, I'd try:
Code:
if ("$x" == "yes') then

Thinking about it a little (assuming your first example works - but it's a typo here) I would try:
Code:
if ("$x" == "yes") then

If $x is a string, you might need to wrap it in single quotes. For instance:
Code:
if ('$x' == "yes") then

Or, you might even try (more conventional coding):
Code:
if ($x == yes) then

Kinda hard to tell without looking at the whole script.
 
Last edited:
Yes, the single quote is a typo. I don't remember the exact error, and if I could reproduce it I wouldn't need to ask the question 🙂

I think the error was the same as what this produces:
if ( == "yes") then
 
I don't remember the exact error, and if I could reproduce it I wouldn't need to ask the question 🙂
Chasing phantom logic errors is great sport, but...

If you cannot reproduce the error, it's a moot question, yes?

Is the script working now?!?!?
 
I prefer to understand why my code works - I prefer to avoid cargo cult programming. So, no, I don't see it as moot.
 
Back
Top