[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

8603.0. "csh and single quote confushion" by PA24::MILLER () Mon Jan 27 1997 14:49

Why in the following script does the ` get seen by csh ?

csh> cat whatswrong
#!/usr/bin/csh
set line=`date`
echo $line
unset line
set line="`date`"
echo $line
unset line
set line='`date`'
echo $line
csh> csh -v whatswrong

set line=`date`
echo $line
Mon Jan 27 14:51:41 EST 1997
unset line
set line="`date`"
echo $line
Mon Jan 27 14:51:41 EST 1997
unset line
set line='`date`'
echo $line
Unmatched `.
T.RTitleUserPersonal
Name
DateLines
8603.1Another csh problem...PEACHS::DALEYMaybe I should drink more coffee...or less!Mon Jan 27 1997 16:5425
The script in .0 works (echoes 'date') on Solaris, HPUX
and AIX, but not on dUNIX 3.2d-1 or 4.0b.

Here's another script with problems.

Should echo:         /usr/products/ftt/v1_5
but instead outputs: $FTT_DIR

It works ok on dUNIX 3.2D-1, AIX, Solaris. 
It fails on dUNIX 4.0b, HPUX.

Any ideas?  Here's the script:

----------------------------------------------------------------------
#!/bin/csh 
#
setenv FTT_DIR /usr/products/ftt/v1_5
setenv UPS_PROD_NAME FTT
eval set PROD_DIR=3D\$`echo $UPS_PROD_NAME | tr '[a-z]' '[A-Z]'`_DIR
echo $PROD_DIR
----------------------------------------------------------------------

Regards,

John
8603.2looks like QAR timeNETRIX::"[email protected]"Farrell WoodsTue Jan 28 1997 11:3514
It was interesting to note that tcsh (as opposed to csh) got what
appeared to be "the right answer".  That is, the final echo parroted
back `date`.

You could still get this to work in csh if it's bothering you:

set line='`date`'
echo "$line"
`date`


	-- Farrell

[Posted by WWW Notes gateway]
8603.3sh > cshPA24::MILLERTue Jan 28 1997 12:376
>You could still get this to work in csh if it's bothering you:

I just came across it chasing down a bug in a script I was writing.
I got around it by using sh.

		tm
8603.4Don't squish everything togetherNETRIX::"[email protected]"Farrell WoodsTue Jan 28 1997 12:5326
Instead of this:

eval set PROD_DIR=\$`echo $UPS_PROD_NAME | tr '[a-z]' '[A-Z]'`_DIR

do this:

eval set PROD_DIR = \$`echo $UPS_PROD_NAME | tr '[a-z]' '[A-Z]'`_DIR


There's probably a subtle difference in how various versions of the shell
tokenize things.  I've seen at least one other instance of this sort of
thing in an old C compiler that supported the (long since) deprecated =op
operators.  That feature of the complier gave vastly different meanings
to these two statements:

	foo=*bar;	/* foo = foo * bar; */
	foo = *bar;

It's sort of like the old jokes about JCL: neatness and precision on the
part of the programmer are encouraged.



	-- Farrell

[Posted by WWW Notes gateway]
8603.5Thanks. More info on .2PEACHS::DALEYMaybe I should drink more coffee...or less!Thu Jan 30 1997 14:3530
Thanks Farrell.

The line in my original example was a bit different, it had characters in front of
it...

  eval set PROD_DIR = 3D\$`echo $UPS_PROD_NAME | tr '[a-z]' '[A-Z]'`_DIR
                      ^^

This gives me the same unexpanded output.  If I do this:


  setenv FTT_DIR /usr/products/ftt/v1_5
  setenv UPS_PROD_NAME \$FTT
                       ^^(added)
 
  eval set PROD_DIR = 3D`echo $UPS_PROD_NAME | tr '[a-z]' '[A-Z]'`_DIR
                      ^^ (\$ removed)
  echo $PROD_DIR


I get the right stuff.

Any idea why the behavior changed from 3.2?  Should we ponder it deeply?  ;)

I'll see if I can get my customer to accept this and be happy.  HP behaves this way,
so it isn't just unix 4.0.

Regards,

JD
8603.6don't know why this would have changedNETRIX::"[email protected]"Farrell WoodsWed Feb 12 1997 15:097
I don't work on the shell so I can't speculate on why that change occurred.
Perhaps someone else might have a bit of insight into that.


	-- Farrell

[Posted by WWW Notes gateway]