gettings child proc. cd's back to parent proc.

Lawrence V. Cipriani lvc at tut.cis.ohio-state.edu
Sat Apr 30 22:29:51 AEST 1988


Someone asked how to get a parent process to change directory
when the child process did it.  This might have nothing to do
with what you want but maybe someone will find this useful ...

If you are talking about shell scripts you could try to
use a shell *function* instead.  Shell functions are in
ksh and System V sh.  I don't know about csh.

Here is one of my favorite shell functions, it makes a
directory and cd's to it all at once.  Put this in your
sh .profile or ksh ENV file:

mc()
{
	case ${#} in
	    1 ) /bin/mkdir ${1} && "cd" ${1} && echo $PWD
		;;
	    * ) echo "usage: ${0} directory" >&2
		return 1
		;;
	esac
}

To use it, just say:

	mc dirname

and voila!  you have a new directory called dirname and you're
there.
-- 
Larry Cipriani, AT&T Network Systems and Ohio State University
Domain: lvc at tut.cis.ohio-state.edu
Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (weird but right)



More information about the Comp.unix.questions mailing list