Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^4: magic-diamond <> behavior -- WHAT?! (sanity)

by ikegami (Pope)
on Oct 30, 2008 at 09:09 UTC ( #720425=note: print w/replies, xml ) Need Help??

in reply to Re^3: magic-diamond <> behavior -- WHAT?! (sanity)
in thread magic-diamond <> behavior -- WHAT?!

Not really. It prevents odd file names from being treated as shell commands, but it dos so by killing your program instead of treating them as the names of files to read as intended.

It's like fixing a flat tire by removing the car's battery. Sure, you won't ruin your car by driving with a flat. But you also won't be driving your car.

  • Comment on Re^4: magic-diamond <> behavior -- WHAT?! (sanity)

Replies are listed 'Best First'.
Re^5: magic-diamond <> behavior -- WHAT?! (sanity)
by Anonymous Monk on Oct 30, 2008 at 11:41 UTC
    Its more like pulling over when you get nailed, then you get out, fix your tire.

      The program won't run with certain file names. <> just won't work with them. Are you suggesting that all scripts should reimplement <> to use 3-arg open? You're talking about extremely tricky code if you don't want to break -i.

        Well, what most people ranting about magic open say is that files ending in '|' get created either by accident, or they are there to try to exploit something. In such cases, I would like to see the files removed; I rather have my filter stop and complain in stead of silently processing the file and leaving the potential exploit there.

        Now, if you actually want to have files that start with '<', '>', '|' or whitespace, or end with '|' or whitespace, then you are in for a lot of suffering - not just from Perl, but from the shell as well. But still, Perl has a documented solution (see for instance, 'perlopentut'):

        BEGIN {s!^(\s)!./$1!,s/^/</,s/$/\0/ for @ARGV}
        Yes, and that works with -i as well.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://720425]
[holli]: so i filed a pull request for a open source project on github, they guy asks me "what motivates me to do this"
[holli]: i am tempted to answer "to please our new asian overlords" or something
[holli]: what a silly question

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-10-18 22:50 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (251 votes). Check out past polls.