home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / wizards / 3796 < prev    next >
Encoding:
Internet Message Format  |  1992-09-04  |  1.5 KB

  1. Path: sparky!uunet!stanford.edu!rutgers!ub!toz!rchandra
  2. From: rchandra@toz.buffalo.ny.us (Dr. R. Chandra)
  3. Newsgroups: comp.unix.wizards
  4. Subject: Re: cd'ing to a dir from
  5. Message-ID: <gate.HwaJqB1w165w@toz.buffalo.ny.us>
  6. Date: 3 Sep 92 16:41:52 GMT
  7. Lines: 31
  8. X-Maildoor: WaflineMail 1.00r
  9.  
  10. > hurtta@cs.Helsinki.FI (Kari E. Hurtta) writes:
  11. >
  12. > >In article <BtA89y.MCt@encore.com> mpalmer@encore.com (Mike Palmer)
  13. > wrote:
  14. > >> Can anyone suggest a way for a process to cd to a dir & stay there
  15. > >> when the process exits.
  16. >
  17. > >So program must modify its parent's environment ...
  18. > >That's magic.
  19. >
  20. > Yesterday I tried out Norton's ncd for Unix (please no more flame wars
  21. > on
  22. > this topic), and it works. But how? I didn't look whether ncd was suid
  23. > root, but how else can the program mess around in the environment? Or
  24. > is
  25. > this on of the kernel changes Norton Utilities for Unix requires?
  26.  
  27. Hmmmm....can't tell you for sure.  But if you think about it, the
  28. inheritance rules for exec(2) should work.  The shell that invokes ncd
  29. by exec(2) instead of fork(2)/exec(2), and then ncd can exec(2) either
  30. another program, or its invoking shell program, which ONLY BY CONVENTION
  31. is in the environment variable SHELL (the invoking shell may or may not
  32. choose to pass the environment it got from its parent program (I realize
  33. this term is usually used for only processes...), usually login(1)).
  34. Ergo, let's for a moment assume csh.  You can do
  35.  
  36.         alias ncd exec ncd
  37.  
  38. or make it a Bourne function (if sh), or whatever.
  39.  
  40.  * Q-Blue v0.7 [NR] *                             
  41.