Help with this script

Tom Christiansen tchrist at convex.COM
Thu Apr 11 08:36:58 AEST 1991


>From the keyboard of hendrik at cca.vu.nl (Hendrik te Winkel):
:Is it really impossible
:to change your working dir with a shell script _and_ to remain there
:after it is finished? I don't know how to do it. Please inform.

This could be rephrased "Is it really impossible to change another
process's environment without that process's cooperation?".  This answer
is generally, yes, this is really impossible.  

There are a few exceptions.  If it's your own process, you may be able to
change its nice value or send it a signal, but you're not going to be able
to change its environment variables, its umask, or its working directory.
Well, modulo a kernel dive:  with kmem write privs, you could munge that
process's u_cdir or u_cmask while it's not looking, but don't tell anyone
I said that. :-)

Much better solutions involve using shell aliases or functions, since they
operate in the same process as the calling shell.  A less good solution
would be to use TIOCSTIs if you have them to jam the right command into
your input buffer so that it's the next thing that your shell reads.

--tom



More information about the Comp.unix.shell mailing list