in reply to Re^7: exec not working?
in thread exec not working?
... why ...
Hmm, found a bug, exec appears to cache path, so it works even if you undef $ENV{PATH}, where as system fails -- I still can't replicate the OPs condition :)
$ perl -V:yo -Te " undef $ENV{PATH}; system q/perl -e die /" yo='UNKNOWN';
$ perl -V:yo -Te " undef $ENV{PATH}; exec q/perl -e die /" yo='UNKNOWN'; $ Died at -e line 1.
$ set path= $ C:\perl\5.12.2\bin\MSWin32-x86-multi-thread\perl.exe -V:yo -Te " und +ef $ENV{PATH}; exec qw/perl -e die /" yo='UNKNOWN';
# using the shell works, perl dies
$ perl -le " exec q{C:\WINDOWS\system32\cmd.exe /x /c }.qq{\x22perl - +e die\x22}; " $ Died at -e line 1.
$ perl -le " undef $ENV{PATH}; exec q{C:\WINDOWS\system32\cmd.exe /x / +c }.qq{\x22perl -e die\x22}; " $ 'perl' is not recognized as an internal or external command, operable program or batch file.
$ perl -V:yo -le " undef $ENV{PATH}; exec q{cmd.exe /x /c }.qq{\x22per +l -e die\x22}; " yo='UNKNOWN'; $ 'perl' is not recognized as an internal or external command, operable program or batch file.
$ set path= $ C:\perl\5.12.2\bin\MSWin32-x86-multi-thread\perl.exe -V:yo -le " un +def $ENV{PATH}; exec q{cmd.exe /x /c }.qq{\x22perl -e die\x22}; " yo='UNKNOWN';
http://perl5.git.perl.org/perl.git?a=search&h=HEAD&st=grep&s=_exec
|
|---|