Where am I (csh)

Mark Komarinski mkomarinski at wayga.org
Wed Jan 15 14:43:42 EST 2003


On Wed, Jan 15, 2003 at 02:34:28PM -0500, Kevin D. Clark wrote:
> 
> Mark Komarinski <mkomarinski at wayga.org> writes:
> 
> > Without getting into the "why are you using X to do the job":
> >
> > I've got a csh script in an arbitrary location.  But I need to know
> > from within the script where it exists in the directory structure.  The
> > reason for that is I need to source a file from within that same
> > directory (where the script is).  If I look for cwd or pwd, I get the
> > directory my shell was when when I ran the script, not where the
> > script itself is located.
> >
> > As an additional condition, I can't use anything on the local system, as
> > the script will be run over NFS to various systems (hence one of the
> > reasons it's arbitrary).  And it has to be csh, no tcshisms.
> 
> Doing this, in the most general case, is very difficult.  It doesn't
> matter which shell you're using either...
> 
> Is `dirname "$0"` good enough?  (even though in certain strange
> situations (that you will probably never experience) it might not be
> correct).
 
echo "$0" in the script in both irix and linux gives:

-tcsh

-Mark (not a shell)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20030115/fac62520/attachment.bin


More information about the gnhlug-discuss mailing list