develooper Front page | perl.perl5.porters | Postings from July 2012

[perl #114120] system() command not handling bash redirects

Thread Next
From:
James E Keenan via RT
Date:
July 13, 2012 14:45
Subject:
[perl #114120] system() command not handling bash redirects
Message ID:
rt-3.6.HEAD-11172-1342215940-52.114120-15-0@perl.org
On Fri Jul 13 01:45:21 2012, PhilEvans wrote:
> This is a bug report for perl from pae9@leicester.ac.uk,
> generated with the help of perlbug 1.39 running under perl 5.14.2.

> 
> Shell redirects in commands passed through "system()" are not
> working properly. Specifically the bash "&>" operator is being
> interpreted as a "&" (i.e. run in background).
> 
> e.g.:
> 
> system ("ls &> some_file");
> 
> Should give no standard output, but create "some_file". This is what
> happens if the ls is called from a bash shell (and what happened in
>    perl
> 15.4.1). But in my Perl install instead "ls &" is executed, i.e. ls
>    gets
> called in the background, and some_file is not created.
> 

Assuming I understand your post correctly, I cannot reproduce the errant
behavior.

On Darwin/PPC:
#####
$ cd tmp/114120/
[114120] 515 $ touch alpha  beta gamma
[114120] 516 $ perl -e 'system(qq{ls &> some_file}) and die "Unable to ls"'
[114120] 517 $ cat some_file
alpha
beta
gamma
some_file
[114120] 518 $ perl -v |head -2 | tail -1
This is perl 5, version 16, subversion 0 (v5.16.0) built for darwin-2level
[114120] 519 $ /usr/local/bin/perl5.14.2 -e 'system(qq{ls &>
some_other_file}) and die "Unable to ls"'
[114120] 520 $ cat some_other_file 
alpha
beta
gamma
some_file
some_other_file
#####

Similar results using Perl 5.16.0 and 5.14.0 on Linux/386.

Thank you very much.
Jim Keenan

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114120

Thread Next


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