No subject


Fri Jan 31 06:23:24 EST 2014


>From suter  Mon Nov 26 14:28:45 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 fAQ4SjNT010214
	for <suter at zwitterion.humbug.org.au>; Mon, 26 Nov 2001 14:28:45 +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 fAQ4Si05022144
	for <suter at zwitterion.humbug.org.au>; Mon, 26 Nov 2001 14:28:44 +1000
Received: from majordom by caliburn with local (Exim 3.12 #1 (Debian))
	id 168D8V-0006Wv-00
	for <general-outgoing at lists.humbug.org.au>; Mon, 26 Nov 2001 14:12:51 +1000
Received: from fox.uq.net.au
	([203.101.255.1] helo=uq.net.au ident=root)
	by caliburn with esmtp (Exim 3.12 #1 (Debian))
	id 168D8T-0006Wq-00
	for <general at lists.humbug.org.au>; Mon, 26 Nov 2001 14:12:49 +1000
Received: from localhost (zzrasmit at localhost [127.0.0.1])
	by uq.net.au (8.9.3/8.9.3) with ESMTP id OAA26327
	for <general at lists.humbug.org.au>; Mon, 26 Nov 2001 14:12:48 +1000 (GMT+1000)
Date: Mon, 26 Nov 2001 14:12:48 +1000 (GMT+1000)
From: Raymond Smith <zzrasmit at uqconnect.net>
X-Sender:  <zzrasmit at fox.uq.net.au>
To: <general at lists.humbug.org.au>
Subject: Re: [H-GEN] change directory shell script reverting to orginal
 directory
In-Reply-To: <4.3.2.7.2.20011126130753.00b0d450 at mail.bigpond.com>
Message-ID: <Pine.OSF.4.30.0111261406580.8061-100000 at fox.uq.net.au>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
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: 1464
Lines: 45

[ 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 ]

Hi ET,

On Mon, 26 Nov 2001, Easo Thankachen wrote:
> i have this script to change to a directory and display the directory
> that it has changed to with some basic validations. But it display the
> correct directory and then reverts back to the directory the command
> was called.

This can be a little confusing when you are getting started. The answer
is:

>#!/bin/sh

starts a whole new command shell. When you change directory within the
script, you are doing so within this shell and not the parent shell
that executed the command.

If instead you ran your script as (under bash):

$ source cwd directory

then the script would be executed by the current shell and the directory
would be changed as you would expect. This is obviously a bit inconvenient
but you could add an alias to do it (again in bash):

$ alias cwd='source ~/bin/cwd $1'

or you could write out the command here (being careful to quote newlines).

Cheers,

Raymond
---
raymond at humbug.org.au   Just once, I'd like to quote someone famous in
			my .sig and spell their name right -- Mi.


--
* 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