cd in a ksh script

cd in a ksh script

Post by Andy Wil » Thu, 02 Mar 1995 05:40:41



Hi,
   how can I cd in a shell script and stay in that directory on exit ??
I dont want to run this as a dot script..
thanks in advance,
    Andy W

--
 --------------------------------------------------------------

| UniKix Technologies.          |                              |
| 13400 N BLACK CANYON HWY      |    Tel: (0101) 602 862 4304  |
| Bldg B   Suite 100            |                              |
| Phoenix AZ   85029            |                              |
 --------------------------------------------------------------

 
 
 

cd in a ksh script

Post by Hrvoje Niks » Thu, 09 Mar 1995 00:17:34



> Hi,
>    how can I cd in a shell script and stay in that directory on exit ??
> I dont want to run this as a dot script..
> thanks in advance,

Unfortunately, there is *no* way to do that.   You also cannot change the
value of a variable (not even environmental) of a parent process.

Hrv

P.S.
But then, there are all kinds of hackers out there.  Watch when you receive
five different successful answers how to do it :-) -- only kidding
--
Hrvoje Niksic                |

http://www.srce.hr/~hniksic/ |  University of Zagreb, Croatia
-------------------------------------------------------------------

 
 
 

cd in a ksh script

Post by Greg Wooled » Fri, 10 Mar 1995 06:16:30




>>    how can I cd in a shell script and stay in that directory on exit ??
>> I dont want to run this as a dot script..
>But then, there are all kinds of hackers out there.  Watch when you receive
>five different successful answers how to do it :-) -- only kidding

#!/bin/sh
cd /some/place
exec ${SHELL-/bin/sh}

Hardly the most elegant solution, but it sure beats the version which
*doesn't* have the exec.... :-)
--
# Greg Wooledge                     /..\