Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: RFC: Perl-Critic policy: ProhibitInlineSystemArgs

by theorbtwo (Prior)
on Jul 01, 2006 at 23:08 UTC ( [id://558811]=note: print w/replies, xml ) Need Help??


in reply to Re^3: RFC: Perl-Critic policy: ProhibitInlineSystemArgs
in thread RFC: Perl-Critic policy: ProhibitInlineSystemArgs

You've got some good points, but you go a bit too far. There's always a way of coding things that doesn't run afowl of this stricture, and it doesn't involve extra work for the coder. It is also, as a nice side-effect, more efficent, and doesn't have a tendency to make things not work on odd filenames. Just do what the shell would yourself, and pass a list of multiple elements, or when you meant to have a single argument, don't put it in double-quotes.

Also, ain't nobody (sane) forcing you to use Perl::Critic. I'm not sure if it's lexical or "no"able, though...


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Replies are listed 'Best First'.
Re^5: RFC: Perl-Critic policy: ProhibitInlineSystemArgs
by BrowserUk (Patriarch) on Jul 01, 2006 at 23:51 UTC
    There's always a way of coding things that doesn't run afowl of this stricture, and it doesn't involve extra work for the coder

    Sorry theorbtwo (nice to see you BTW), but that just isn't so. Take

    system 'myprog | tee mylog | sort >myfile.sorted';

    Perhaps you would consider how little (much) extra work is involved for the coder to achieve the above without using the shell?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      I would write something that would make that easy, something like this, which would take a little more work to output to a file at the end of the pipe, and to use the indirect object syntax of exec, so that even a command with no arguments is (update: slightly more) secure.

        But your missing the very first step. You need to decide what type of file myprog is, where it is, what executable is required to run it, then locate that executable and invoke it with myprog as it's argument long before you reach the point of needing to re-invent the wheel of command pipelinining.

        ... so that even a command with no arguments is secure.

        And how are you going invoke this mythical "secure perl script"? Via a shell?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-03-28 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found