Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!ogicse!intelhf!ichips!iwarp.intel.com!gargoyle!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.lang.perl Subject: Re: pwd? Message-ID: <1991Apr23.145850.6064@chinet.chi.il.us> Date: 23 Apr 91 14:58:50 GMT References: <6330@male.EBay.Sun.COM> <1991Apr17.165554.16507@iwarp.intel.com> <129476@uunet.UU.NET> Organization: Chinet - Chicago Public Access UNIX Lines: 21 In article <129476@uunet.UU.NET> rbj@uunet.UU.NET (Root Boy Jim) writes: >>Unless you're willing to stat a lot of directories, the fastest way is: >> >> chop($path = `cd $name && pwd`); >I have never seen a shell that treated cd properly with respect >to && and ||. Try "cd /bogon || echo failed". The "proper" thing for any shell that offers to run /bin/sh scripts to do is to exit immediately with an error status when a cd fails. Unfortunatly some don't, and more unfortunate there is no way to control it (i.e. IMHO as a sometimes useful extension there should be an option to enable it in a script that expects to continue past a cd). As it is, all those historically correct shell scripts that cd somewhere ; rm -f * will happily eat your current directory when you replace /bin/sh with ksh and "somewhere" goes away. Anyway, just to maintain some relevance to perl - in the above case it doesn't matter much. Les Mikesell les@chinet.chi.il.us