There wasn't last time I tried this about 20 years ago.  :-(

The reason is the architecture of the UNIX file system, where file contents 
actually reside in inodes, and directory entries are really only links to 
inodes.

For example, you create a script.  Now you put a hard link to that script from 
two other directories.  Now you ask the script "where it is."  Which of the 
three locations do you want it to return?  As far as the file system is 
concerned, none of them is any "more authoritative" than another.

On Jul 21, 2013, at 1:16 PM, Michael <keybou...@gmail.com> wrote:

> I feel silly for asking this. But I just realized I don't try this very often.
> 
> Is there a way for a shell script to find itself? Or more precisely, the 
> directory it is in?
> 
> I am trying to run a program that wants an ini file specified on the command 
> line; but it defaults to the assumption of having its config file in /etc 
> unless you tell it where it is. And rather than a one-line script that hard 
> codes a directory, I'd rather that it (the script) can tell where it is 
> located, to use an ini file there.
> 
> (Yea, a one-line script to just pass a config file argument to a program.)
> 
> ---
> This message was composed with the aid of a laptop cat, and no mouse
> 
> _______________________________________________
> MacOSX-talk mailing list
> MacOSX-talk@omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/macosx-talk

_______________________________________________
MacOSX-talk mailing list
MacOSX-talk@omnigroup.com
http://www.omnigroup.com/mailman/listinfo/macosx-talk

Reply via email to