develooper Front page | perl.beginners | Postings from February 2002

Cwd behavior when $PATH is not there - bug or feature?

From:
Adriano Rodrigues Ferreira
Date:
February 21, 2002 19:14
Subject:
Cwd behavior when $PATH is not there - bug or feature?
Message ID:
KGMK8562VKH4Y96LJRL1ZGF51VQ1ZPL.3c754daa@inf-10

I have encountered a behavior that I think it is a little
odd and I have discovered it has to do with the standard
module Cwd. I had a Perl script which was called by
a Java application via Runtime.getRuntime().exec()

I have discovered that it was a good idea to use the
form that includes not only the name of the command
(in the case, something like "c:\perl\bin\perl.exe script.pl")
but also some minimum of the environment.
The application used to stop complaining about Cwd
which could not split an undefined object in line 103
(I'm using Windoze 2000, ActivePerl 5.6.1)
This line reads as

if($^O eq 'MacOS' || grep { -x "$_/pwd" } split(':', $ENV{PATH})) {

The point is that the Java application called the Perl interpreter
with no value for $PATH environment variable and this
caused Cwd to die.

I don't think this is desirable. A simple modification in the Cwd
would check for the defineteness of $ENV{PATH} before
accessing it.

What do you think?

Regards,

Adriano.







nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About