Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: Parallelization of heterogenous (runs itself Fortran executables) code

by Dominus (Parson)
on Nov 21, 2007 at 22:13 UTC ( #652259=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Parallelization of heterogenous (runs itself Fortran executables) code
in thread Parallelization of heterogenous (runs itself Fortran executables) code

Here is a version using Text::ParseWords and a modified spawn subroutine, which uses exec in scalar context.
I think that was an extremely bad move, because now you have to worry about shell metacharacters in arguments, which you formerly did not. For example, consider:
runN echo '*'
We are expecting this to run one echo to print out a star, but with your implementation, it does not; the quotes are stripped off and it echoes a list of the filenames in the current directory.

Similarly, suppose a file in the current directory is named foo bar. Then runN command * will run the command not with the argument foo bar but with the two arguments foo and bar.

Now let's suppose there is a file in the current directory named `rm -rf /`. (Note backquotes!) Then running your version of runN command * will erase the entire filesystem.

I wrote a blog entry about the perils of multiple shell evaluation in this context. I said:

My fear was that by introducing a double set of shell-like interpretation, I'd be opening a horrible can of escape character worms and weird errors, and my hope was that if I ignored the issue the problems might be simpler, and might never arise in practice.
This is exactly the sort of thing I was worried about. Your implementation certainly proves that I was correct about at least the first part of this prediction!


Comment on Re^4: Parallelization of heterogenous (runs itself Fortran executables) code
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2015-07-03 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls