Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
- To: "MLUG Members" <EMAIL:PROTECTED>
- Subject: Re: [MLUG] shell script - find shell script parent directory?
- From: "Jonathan King" <EMAIL:PROTECTED>
- Date: Tue, 4 Mar 2008 12:30:06 -0500
- Delivery-date: Tue, 04 Mar 2008 11:30:33 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=/77UKehM+xWpx5+2f+XvEArwanq18QZ8bmCjxTEUrPE=; b=lr62q/KVj71XQw0M1/2htrS8VD/iIS4dk6utOqKHKz3hrm/SYcVpWpDaz503QNbpDhlGF4RZmNsr70+8AHKsL9cwJfuH4mf35CCkoprKF84R1+lTbPDs6db+xuqNWhz7sT5efyKR6piRYid4pV9culdH3alPf9xbozX4cYKl8BE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=KubF7NGyztfPqw0oQWAWLXGso8HgsACcNWr607n3c0zhq3Z6mutr99D2pcQOkc0E4Pt/QscmxN7Ib8eZdffEbnEqv6PYybjar2Mov4RNjjZirWWmcOAi+F5ohQswjw+WPefV8dShTvaRpwkTF12eKtX+Di0vqhIUOLpZIpW8SKs=
- Envelope-to: EMAIL:PROTECTED
- In-reply-to: <EMAIL:PROTECTED>
- References: <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED>
- Reply-to: MLUG Members <EMAIL:PROTECTED>
- Sender: EMAIL:PROTECTED
On 3/3/08, Mike Miller <EMAIL:PROTECTED> wrote:
> On Mon, 3 Mar 2008, Mike Miller wrote:
>
> > On Mon, 3 Mar 2008, Robert Citek wrote:
> >
> >> On Sat, Mar 1, 2008 at 12:16 PM, Mike Miller <EMAIL:PROTECTED>
> >> wrote:
> >>
> >>> We had a fairly long discussion about this on TCLUG (Twin Cities) and
> >>> I thought you guys also would find it interesting and informative.
> >>> It started with this question about bash scripting:
> >>>
> >>> I'm trying to find a variable or a command that will tell me where
> >>> the currently executing script lives.
> >>
> >> I'll take a stab:
> >>
> >> $cat foo.sh
> >> #!/bin/bash
> >> echo $0
>
>
> Robert wrote to me off-list because he wanted to give the rest of you a
> chance to come up with something. I haven't heard anything, so maybe the
> interest isn't there, or maybe you were waiting to see how Robert would
> respond to my comments. In case it was the latter, this is what he came
> up with next:
>
> #!/bin/bash
> ( cd "${0%/*}" ; pwd -P )
>
> That is very cool and it is similar to what we came up with on TCLUG.
> There are several little tricks worth adding though. What happens if the
> filename or directory name begins with a minus sign?
I guess you could escape it...
> How can we be sure
> that the bash builtin versions of cd and pwd are used?
Can you over-ride that from happening? In any case, a horrible hack
would be to parse the output of "which", which should report that
these are built-ins. Note: I don't have a appropriate test bed here at
work for any of this.
jking
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members