> > On Tue, 2006-01-31 at 17:39 -0600, > [EMAIL PROTECTED] wrote: > > On Tue, Jan 31, 2006 at 09:26:21PM +0000, michael wrote: > > > On Tue, 2006-01-31 at 10:16 -0500, Juergen Fiedler wrote: > > > > On Tue, Jan 31, 2006 at 02:26:27PM +0000, michael wrote: > > > > > Presuming I have a file setEnvVars.sh that I wish to source, > > > > > . path/setEnvVars.sh > > > > > How do I, within the script, determine the actual directory within > > > > > which > > > > > the setEnvVars.sh file sits? The sourcing seems to disallow me access > > > > > to > > > > > $0 etc > > > > > > > > > > thanks, M > > > > Hi Michael, > > > > perhaps ${BASH_ARGV[0]} can help you? > > > > ] [EMAIL PROTECTED]:~/tmp$ cat ../X.sh > > ] #!/bin/bash > > ] set | grep BASH_ARG > > ] [EMAIL PROTECTED]:~/tmp$ ../X.sh > > ] BASH_ARGC=() > > ] BASH_ARGV=() > > ] [EMAIL PROTECTED]:~/tmp$ . ../X.sh > > ] BASH_ARGC=([0]="1") > > ] BASH_ARGV=([0]="../X.sh") > > ] [EMAIL PROTECTED]:~/tmp$ cd .. > > ] [EMAIL PROTECTED]:~$ cd tmp > > ] [EMAIL PROTECTED]:~/tmp$ . ../X.sh > > ] BASH_ARGC=([0]="1") > > ] BASH_ARGV=([0]="../X.sh") > > > > BASH_ARG[CV] carry the argument lists of the subroutine calls currently on > > the execution stack - and 'source' (or '.') qualifies as a subroutine, so > > its argument (the filename to be sourced) is on the stack. This, in > > combination > > with $(pwd), should be sufficient to locate the sourced file. > > > > > > HTH, > > > > Jan
that sounds more like what I would like, however I don't see to have BASH_ARG... [EMAIL PROTECTED]:/tmp$ set | grep -i bash BASH=/bin/bash BASH_PROFILE=run BASH_VERSINFO=([0]="2" [1]="05b" [2]="0" [3]="1" [4]="release" [5]="i386-pc-linux-gnu") BASH_VERSION='2.05b.0(1)-release' HISTFILE=/home/michael/.bash_history SHELL=/bin/bash [EMAIL PROTECTED]:/tmp$ cat > test.sh #!/bin/bash set | grep BASH_ARG [EMAIL PROTECTED]:/tmp$ cat test.sh #!/bin/bash set | grep BASH_ARG [EMAIL PROTECTED]:/tmp$ chmod u+x test.sh [EMAIL PROTECTED]:/tmp$ ./test.sh [EMAIL PROTECTED]:/tmp$ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]