FAQ

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

Search Discussions

  • Eric Brine at Jul 13, 2012 at 10:03 pm

    On Fri, Jul 13, 2012 at 5:45 PM, James E Keenan via RT wrote:
    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).
    Perl doesn't use bash. It uses sh. If you want to use bash, use

    system ("bash", "-c", "ls &> some_file");
  • Tom Christiansen at Jul 13, 2012 at 10:10 pm

    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.

    That's the correct behavior. system uses Bourne shell syntax,
    not bash.

    --tom

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedJul 13, '12 at 9:45p
activeJul 13, '12 at 10:10p
posts3
users3
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase