Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!swrinde!ucsd!helios.ee.lbl.gov!nosc!humu!pegasus!richard From: richard@pegasus.com (Richard Foulk) Newsgroups: comp.lang.perl Subject: Re: How to find working directory? Message-ID: <1990Aug5.115155.10191@pegasus.com> Date: 5 Aug 90 11:51:55 GMT References: <8974@jpl-devvax.JPL.NASA.GOV> <21198@duke.cs.duke.edu> <104612@convex.convex.com> Organization: Pegasus, Honolulu Lines: 19 X-Local-Date: 5 Aug 90 04:51:55 PDT >>GNU Emacs uses PWD if it exists. my normal login shell updates PWD >>but /bin/csh doesn't (under 4.3BSD) so when i fire up emacs after >>su'ing to another user, emacs gets the wrong directory. i'd say this >>is busted. > >I'm not sure which you say is busted. It seems highly suspect >to look at your environment for the $PWD. It's like trusting >it for $USER. Use getwd() and getpwnam(getuid()) for these. >What if a program does its own chdir() followed by an exec() >or system()? The only time $USER isn't trusted is when security is at stake. Having a $PWD that is incorrect seems very ungood to me. You could at least remove it from the environment if you know it's wrong. -- Richard Foulk richard@pegasus.com