help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Finding full path of sourced script


From: Greg Wooledge
Subject: Re: [Help-bash] Finding full path of sourced script
Date: Tue, 4 Sep 2012 08:23:09 -0400
User-agent: Mutt/1.4.2.3i

On Tue, Sep 04, 2012 at 01:15:00PM +0200, Suvayu Ali wrote:
> I wanted to find the full path of a sourced script.  I cannot use
> something like `basename $0` as $0 points to $BASH.

http://mywiki.wooledge.org/BashFAQ/028

> Is there a better alternative?

As I wrote on that wiki page, your best bet is either to hardcode the
path of your data files inside the script, or to read a configuration
file from a static location such as /etc/yourscript/config or
$HOME/.yourscript.

Trying to determine "where the user put my script and its associated
data files on the disk" is an impossible game.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]