Re: @ARGV array incorrect when calling perl program from system
- From: Udo Grabowski <udo.grabowski@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 03 Sep 2009 15:48:30 +0200
Peter Makholm wrote:
Udo Grabowski <udo.grabowski@xxxxxxxxxxxxxxxxxxxxx> writes:
@command = ("perl-program","--help",">","logfile");
eval { system(@command) };
Read the documentation for the system command:
If there is more than one argument in LIST, or if LIST is an array
with more than one value, starts the program given by the first
element of the list with arguments given by the rest of the list.
So of course '>' and 'logfile' is parsed to the script as script
arguments. If you need any kind of shell handling, you have to use
one, and only one, argument to system.
So this means that calling 'perl-program --help > logfile' and
using the construction above (which should be equivalent, since
it should be transparent to the program from whom it is called)
will give inconsistent @ARGV arrays. So I still consider this
to be a bug (referring to Unix semantics) instead of a feature.
If this is really Posix' definition, then Posix is inconsistent.
But I think that 'system' called here is the perl implementation,
so maybe that is simply done wrong there.
Workaround is indeed to call it this way:
$return=system('perl-program --help > logfile')
.
- Follow-Ups:
- Re: @ARGV array incorrect when calling perl program from system
- From: RedGrittyBrick
- Re: @ARGV array incorrect when calling perl program from system
- From: Lawrence Statton
- Re: @ARGV array incorrect when calling perl program from system
- References:
- @ARGV array incorrect when calling perl program from system
- From: Udo Grabowski
- Re: @ARGV array incorrect when calling perl program from system
- From: Peter Makholm
- @ARGV array incorrect when calling perl program from system
- Prev by Date: Re: @ARGV array incorrect when calling perl program from system
- Next by Date: Re: @ARGV array incorrect when calling perl program from system
- Previous by thread: Re: @ARGV array incorrect when calling perl program from system
- Next by thread: Re: @ARGV array incorrect when calling perl program from system
- Index(es):
Relevant Pages
|