T.R | Title | User | Personal Name | Date | Lines |
---|
8603.1 | Another csh problem... | PEACHS::DALEY | Maybe I should drink more coffee...or less! | Mon Jan 27 1997 16:54 | 25 |
| 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.2 | looks like QAR time | NETRIX::"[email protected]" | Farrell Woods | Tue Jan 28 1997 11:35 | 14 |
| 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.3 | sh > csh | PA24::MILLER | | Tue Jan 28 1997 12:37 | 6 |
| >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.4 | Don't squish everything together | NETRIX::"[email protected]" | Farrell Woods | Tue Jan 28 1997 12:53 | 26 |
| 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.5 | Thanks. More info on .2 | PEACHS::DALEY | Maybe I should drink more coffee...or less! | Thu Jan 30 1997 14:35 | 30 |
| 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.6 | don't know why this would have changed | NETRIX::"[email protected]" | Farrell Woods | Wed Feb 12 1997 15:09 | 7 |
| 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]
|