No subject
Fri Jan 31 06:23:24 EST 2014
>From suter Mon Nov 26 16:19:24 2001
Return-Path: <majordom at caliburn.humbug.org.au>
Received: from diadora.client.uq.net.au (diadora-2 [10.0.1.2])
by zwitterion.humbug.org.au (8.12.1/8.12.1/Debian -2) with ESMTP id fAQ6JNNT028316
for <suter at zwitterion.humbug.org.au>; Mon, 26 Nov 2001 16:19:23 +1000
Received: from caliburn (mail at caliburn.humbug.org.au [203.15.51.6])
by diadora.client.uq.net.au (8.12.1/8.12.1/Debian -2) with ESMTP id fAQ6JN05024416
for <suter at zwitterion.humbug.org.au>; Mon, 26 Nov 2001 16:19:23 +1000
Received: from majordom by caliburn with local (Exim 3.12 #1 (Debian))
id 168Etq-0007C2-00
for <general-outgoing at lists.humbug.org.au>; Mon, 26 Nov 2001 16:05:50 +1000
Received: from azure.humbug.org.au ([203.143.238.84] ident=mail)
by caliburn with esmtp (Exim 3.12 #1 (Debian))
id 168Etm-0007Bx-00
for <general at lists.humbug.org.au>; Mon, 26 Nov 2001 16:05:47 +1000
Received: from aj by azure.humbug.org.au with local (Exim 3.12 #1 (Debian))
id 168Etj-0001LR-00; Mon, 26 Nov 2001 16:05:43 +1000
Date: Mon, 26 Nov 2001 16:05:43 +1000
To: general at lists.humbug.org.au
Subject: Re: [H-GEN] change directory shell script reverting to orginal directory
Message-ID: <20011126160543.B4925 at azure.humbug.org.au>
Mail-Followup-To: general at lists.humbug.org.au
References: <4.3.2.7.2.20011126130753.00b0d450 at mail.bigpond.com> <Pine.OSF.4.30.0111261406580.8061-100000 at fox.uq.net.au> <4.3.2.7.2.20011126145301.00b1a0f8 at mail.bigpond.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
In-Reply-To: <4.3.2.7.2.20011126145301.00b1a0f8 at mail.bigpond.com>; from easo.thankachen at mat-man.com.au on Mon, Nov 26, 2001 at 03:39:33PM +1000
Organisation: Lacking
X-PGP: http://azure.humbug.org.au/~aj/aj_key.asc
From: Anthony Towns <aj at azure.humbug.org.au>
Precedence: bulk
Reply-To: general at lists.humbug.org.au
X-Loop: general at lists.humbug.org.au
List-Help: <mailto:majordomo at lists.humbug.org.au?subject=help>
List-Post: <mailto:general at lists.humbug.org.au>
List-Subscribe: <mailto: general-request at lists.humbug.org.au?subject=subscribe>
List-Id: semi-serious discussions about Humbug and Unix-related topics <general at lists.humbug.org.au>
List-Unsubscribe: <mailto: general-request at lists.humbug.org.au?subject=unsubscribe>
List-Archive: <http://archive.humbug.org.au/humbug-general/>
Sender: Majordomo <majordom at caliburn.humbug.org.au>
Status: RO
Content-Length: 2098
Lines: 58
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Please observe the list's charter. ]
[ Worthwhile understanding: http://www.humbug.org.au/netiquette.html ]
On Mon, Nov 26, 2001 at 03:39:33PM +1000, Easo Thankachen wrote:
> I had a feeling it was landing back in the parent shell.
You are, yes. You could avoid that by making your script be:
#!/bin/sh
cd $1
exec bash
which would keep you in a sub-shell each time, and would mean you'd have to
type exit once for each invocation of that script to log out.
> I tried taking of the #!/bin/sh , but that did not help. The solution you
> suggested seems to be shell specific.
Yes, the solution's always shell specific. A script is just a special
sort of program, and program's don't get to mess with the insides of
whatever program invoked them, generally speaking. If you want to mess
with the insides of your shell, you need to do it specially, and the way
to do that is by "sourcing" the script, rather than executing it.
$ . /usr/local/bin/cwd
is the POSIX sh way of doing it (should work in sh, bash, ksh, zsh).
$ source /usr/local/bin/cwd
is a bash alias for it.
> Would there be some command/directive that will force the script to be
> executed in the same shell.
> Such a simple script probably should not be shell specific.
It's always shell specific. It has to be shell specific to be able to
muck around with the internals of the shell without breaking things.
Cheers,
aj
--
Anthony Towns <aj at humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG signed mail preferred.
"Security here. Yes, maam. Yes. Groucho glasses. Yes, we're on it.
C'mon, guys. Somebody gave an aardvark a nose-cut: somebody who
can't deal with deconstructionist humor. Code Blue."
-- Mike Hoye,
see http://azure.humbug.org.au/~aj/armadillos.txt
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.
More information about the General
mailing list