Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <8C36CEF2AF34D211922D00A0C9D60A5405A2B4@epimail.epigram.com> From: Christopher Warth To: gnu-win32 AT cygnus DOT com Subject: nesting "source" scripts Date: Sun, 21 Feb 1999 14:59:15 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" This looks like it is simply a bash bug rather than anything specific to cygwin but snce I encountered this using cygwin I will try to find the answer here first. It looks like the full path name of bash scripts is not available when they are invoked with "source". This makes it impossible to call other scripts in the same directory, no? Consider the two bash scripts in the same directory, A.sh and B.sh A.sh -- #!bash echo A: $0 source B.sh B.sh -- #!bash echo B: $0 echo Inside of B! If CWD (current working directory) is the same as the location of A.sh and B.sh, you can simply type $ source A.sh A: bash B: bash Inside of B! and it will all work. However, if CWD is someplace else, and you type a/long/path/A.sh it seems there is no way for A.sh to correctly find the B.sh script without hardcoding the path into A.sh. You might think you would simply take the directory component of $0 and use that to help find the full path of A.sh. That does not work because when invoking a script with "source" (and only then!) $0 is always set to just "bash", not the path of script. Thus as far as I can tell there is no way to nest scripts that might be invoked with "source", short of hardcoding paths. Is this true? If so, it sure seems like a bug. -csw -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com