delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/08/11:53:34

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Subject: Re: Using PWD
To: cygwin AT cygwin DOT com
Cc: david AT tvis DOT co DOT uk
Message-ID: <OFEDDC7F2E.4C40A590-ON88256FA2.005B9AA5-88256FA2.005CAFD1@mck.us.ray.com>
From: Arthur I Schwarz <Arthur_I_Schwarz AT raytheon DOT com>
Date: Tue, 8 Feb 2005 08:52:23 -0800
MIME-Version: 1.0
X-SPAM: 0.00

Well, you got me all enthused, sigh :-(.

Which requires a path. The objective (here) is not to put the scripts on a
path because they are transient and using PATH would be overkill. So:

./<my_script>               Which does indeed provide a path ('.'). But so
does dirname $0.
source scripts/<my_scripts> Which can't find <my_scripts>. `dirname $0`
returns 'bash', and as an added mystery if the code looks like:

     echo $0
     echo `dirname $0`
     which -a <my_script>

the system also crashes my bash shell.

Oh well.

art

On Sun, 6 Feb 2005 09:20:53 -0800,  wrote:

>I'm trying to find the directory of an executing bash script and am having
>very limited success. For example(s):
>
>1. <path>/script.sh
>2. source <path>/script.sh
>3. bash <path>/script.sh
>
>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?
>
>art
>
Art,
unless I'm missing something you want

which -a your_script


zzapper (vim, cygwin, wiki & zsh)
--

vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?"

http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019