[comp.sys.sun] $cwd in shell vs $cwd in shell script?

kovar%husc4@talcott.harvard.edu (-David C. Kovar) (01/11/89)

I'm running OS 4.0.0 on a Sun386i. I'd like to make symbolic links from a
file in my home directory on icarus to a spool directory on daedalus using
a shell script. So I do something like:

  ln -s $cwd/$filename /usr/spool/slide

where /usr/spool/slide is a NFS mounted directory on daedalus. This
results in a command that looks like:

  ln -s /files/home2/corwin/doslide /usr/spool/slide/doslide

which is incorrect as doslide is really in /net/icarus/files..... Or, as
the shell reports it, /home/corwin/doslide.

So, my question: why, if I type echo $cwd to the shell, do I get
"/home/corwin" but, if I use $cwd in a shell script, do I get
"/files/home2/corwin"? There is probably a trivial answer but I can't find
it in the FMs for automount, csh, pwd, and the like.

-David Kovar
 kovar@husc4.harvard.edu

[[ There's some missing data:  what exactly is in /files/home2?  Was this
name pulled out of a hat, or is there a reason that it is using that name?
I don't know if this bit of informatino will help, but:  $cwd is set when
the cshell starts (at login time for a login shell) and is modified based
on the arguments to "cd" commands.  It is conceivable, given symbolic
links, that $cwd in the login shell will not be the same as a $cwd in a
newly started sub-cshell---just like "/bin/pwd" won't always give you the
same string that "echo $cwd" will.  --wnl ]]