Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Backticked commands and the readpipe blues

by Flexx (Pilgrim)
on Sep 23, 2002 at 15:25 UTC ( #200131=note: print w/replies, xml ) Need Help??

in reply to Backticked commands and the readpipe blues

Hi, grinder!

Maybe I completely miss your point, but what's wrong about

my @args = map { ($_, foo($arg{$_})) } keys %args; # either: prepend \ to all $ in @args s/\$/\\\$/g foreach @args; # or maybe: quote all single quotes, then single-quote all args s/'/\\'/g foreach @args; @args = map "'$_'", @args; my @output = `/bin/foo @args`;

Am I missing something?

So long,

Replies are listed 'Best First'.
Re:x2 Backticked commands and the readpipe blues
by grinder (Bishop) on Sep 23, 2002 at 16:37 UTC
    What you're missing is the fact that I want to bypass the shell. I don't want to subject to its quoting rules and I don't want it to see 'foo;rm -rf /'. I don't want to second-guess the shell by escaping metacharacters and hope I get them all... I just don't want to have to worry at all.

    And from my dim, dark memories of shell programming, to quote a single quote, e.g. don't, you have to say 'don'"'"'t', which means that your code would produce incorrect results. This stuff is tricky!

    Backticking is a concise construct for extracting output from external programs, but as things stand, you cannot avoid bringing the shell into the picture. If you could be certain that you were calling the child program directly, a lot of the security hassle would magically evaporate.

    It's another "Doctor, Doctor" story.

    Patient: Doctor, doctor, when I stick my arm out the car window, it gets smashed to pieces by a passing truck.
    Doctor: Well, don't do that then.

    If I knew I didn't have to stick my arm out, I'd be fine. But the only way to do that in the current scenario is to go through all the hoops of forking and listening to my child. In my books this is One More Damned Thing To Go Wrong. Programming Perl, the book, hinted that in the future such a thing was going to be possible, but on the face of things it looks like it was an idea never went anywhere.

    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

      Hi grinder!

      Thanks for the clarification.. I did indeed not see that you'd actually really, really want to bypass the shell.. ;)

      Under that aspect, in a way, it's just fair you'll have to cope with what the shell usually does for you... ;)

      If I recall correctly, system() calls execvp(), maybe you could do that yourself. But that would, of course, involve XS hacking, something I didn't want to touch so far (which might turn out to be a fear of nothing once I do). Then again, maybe there's something out there already...

      Umm... I wish I could be of more help...

      Good luck & so long,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2022-09-30 03:40 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (125 votes). Check out past polls.