1 ;# pwd.pl - keeps track of current working directory in PWD environment var
3 ;# $RCSfile: pwd.pl,v $$Revision: 4.1 $$Date: 92/08/07 18:24:11 $
17 local($dd,$di) = stat('.');
18 local($pd,$pi) = stat($ENV{'PWD'});
19 if ($di != $pi || $dd != $pd) {
20 chop($ENV{'PWD'} = `pwd`);
24 chop($ENV{'PWD'} = `pwd`);
26 if ($ENV{'PWD'} =~ m|(/[^/]+(/[^/]+/[^/]+))(.*)|) {
27 local($pd,$pi) = stat($2);
28 local($dd,$di) = stat($1);
29 if ($di == $pi && $dd == $pd) {
36 local($newdir) = shift;
37 $newdir =~ s|/{2,}|/|g;
39 if ($newdir =~ m#^/#) {
40 $ENV{'PWD'} = $newdir;
43 local(@curdir) = split(m#/#,$ENV{'PWD'});
44 @curdir = '' unless @curdir;
45 foreach $component (split(m#/#, $newdir)) {
46 next if $component eq '.';
47 pop(@curdir),next if $component eq '..';
48 push(@curdir,$component);
50 $ENV{'PWD'} = join('/',@curdir) || '/';