Subject: | Argv finds external command even if environment is empty |
Date: | Fri, 31 May 2013 11:00:31 +0200 |
To: | bug-Argv [...] rt.cpan.org |
From: | Dirk Heinrichs <dirk.heinrichs [...] altum.de> |
Hello,
don't know wether it's really a bug, but at least something I'd like
to understand. I was testing a program that is using Argv for wether
it can be used from cron, so I started it with
env -i ./myprogram.pl
to start it with an empty environment and found out it worked,
although I used only the basename of the external programs I called
via Argv. So my question is: Why is it working at all, given that the
environment is empty? I was expecting that it failed with some kind of
"No such file or directory" error.
The following small program shows the behaviour:
#!/usr/bin/perl
use strict;
use warnings;
use Argv;
my $cmd=Argv->new({autochomp=>1,autofail=>1,dbglevel=>2});
# Verify environment is empty
print ("Environment:\n");
foreach my $key ( sort( keys(%ENV) ) )
{
printf( "%s=%s\n", $key, $ENV{$key} );
}
# Call external command
print ("Calling external command:\n");
$cmd->hg("--version")->system;
exit (0);
It gives the following output when started via "env -i":
$ which hg
/usr/local/bin/hg
$ env -i ./argv_test.pl
Environment:
Calling external command:
+ hg --version
Mercurial Distributed SCM (version 1.9)
(see http://mercurial.selenic.com for more information)
Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
+ ($? == 0)
How comes?
Thanks...
Dirk
--
Dirk Heinrichs <dirk.heinrichs@altum.de>
Tel: +49 (0)2471 209385 | Mobil: +49 (0)176 34473913
GPG Public Key C2E467BB | Jabber: dirk.heinrichs@altum.de
Message body not shown because it is not plain text.