Using PWD

linda w
Mon Feb 7 07:40:00 GMT 2005

the 3rd example works with dirname $0 as well.

In your 2nd example there is no script that is running.  The
commands in the script are read as though you typed them in from
the terminal -- which means there is no "scriptname" to find
the name of.

You could check if $0 is equal to a shell name and give an error,
but source <command_list> isn't equivalent to calling a shell

Sorry don't have any better answers for #2...

Arthur Schwarz wrote:

>I'm trying to find the directory of an executing bash script and am having
>very limited success. For example(s):
>1. <path>/
>2. source <path>/
>3. bash <path>/
>I can find the correct <path> only for the first example (dirname $0). PWD
>(of course) only works when <path> == ./. The other two cases I can't seem
>to get to work. Any idea how to get the <path> in examples 2 and 3?

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list