🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #10157

$cwd in shell vs $cwd in shell script?

#10157
From: -David C. Kovar
Date: Wed, 11 Jan 1989 13:27
30 lines
1933 bytes
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 ]]
Technical Details
Message-ID: <8901032305.AA10090@icarus>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!killer!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!killer!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request
From: daedalus!kovar%husc4@talcott.harvard.edu (-David C. Kovar)
Newsgroups: comp.sys.sun
Subject: $cwd in shell vs $cwd in shell script?
Message-ID: <8901032305.AA10090@icarus>
Date: 11 Jan 89 13:27:56 GMT
Sender: usenet@rice.edu
Organization: ATT Bell Labs, Andover, MA
Lines: 30
Approved: Sun-Spots@rice.edu
Original-Date: Tue, 03 Jan 89 18:05:36 -0500
X-Sun-Spots-Digest: Volume 7, Issue 95, message 12 of 21