Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: system "no_such_file" returns a different error on Fedora

by chromatic (Archbishop)
on Jul 03, 2008 at 16:53 UTC ( #695390=note: print w/replies, xml ) Need Help??


in reply to system "no_such_file" returns a different error on Fedora

Hm, that looks like a bad test to me.

$rc = system { "lskdfj" } "lskdfj"; unless( ok($rc == 255 << 8 or $rc == -1 or $rc == 256 or $rc == 512) ) + { print "# \$rc == $rc\n"; } unless ( ok( $! == 2 or $! =~ /\bno\b.*\bfile/i or $! == 13 or $! =~ /permission denied/i or $! == 22 or $! =~ /invalid argument/i ) ) { printf "# \$! eq %d, '%s'\n", $!, $!; }

By the time something gets around to checking $!, won't all of the system calls performed by ok() and print have set it to something else?

Replies are listed 'Best First'.
Re^2: system "no_such_file" returns a different error on Fedora
by amir_e_a (Hermit) on Jul 03, 2008 at 17:47 UTC

    A good point, although it seems to work like this on my Fedora machine with this minimal program:

    system { "lskdfj" } "lskdfj"; printf "# \$! eq %d, '%s'\n", $!, $!; # prints # $! eq 20, 'Not a dire +ctory'

    Another minor problem i can think of is the "random" command "lskdfj". It's paranoid thinking, but what if the user happens to have a file called /bin/lskdfj ? Maybe it should be checked with -e or something.

    I'd bring it up on perl5-porters, but i am trying to subscribe and not receiving the confirmation email.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://695390]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2020-01-21 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?