in reply to Re^6: magic-diamond <> behavior -- WHAT?!
in thread magic-diamond <> behavior -- WHAT?!

How about rm -i *? Do you think it's safe, specially because you asked it to ask you before removing a file? You'd be surprised if there's a file name -f. How about scp * remote:? That might do something unexpected there's a file somehost:bla, or even otherhost:*.

There's no guarantee any program treats a filename given as argument as nothing else than a filename. In fact, most programs don't. And you should be quite aware of that when using *, or any other form of expansion (for instance, when using find ... | xargs). Being aware of what you are doing is far more useful than removing magic open.

It's like saying let's equip every Toyota with safety belts.
That doesn't help the person crossing the street with his eyes closed, does it?

Replies are listed 'Best First'.
Re^8: magic-diamond <> behavior -- WHAT?!
by zwon (Abbot) on Oct 28, 2009 at 17:07 UTC

    That's certainly a point. But here's also some difference -- man pages for both rm and scp explicitly mention these cases and how to workaround them, documentation for prove doesn't.

      Then fix the documentation! Changing Perl because documentation of applications is incorrect or incomplete isn't the way to go.
        Then fix the documentation!

        I think I should fix the scripts. I don't think that's their intended behavior.

        Changing Perl because documentation of applications is incorrect or incomplete isn't the way to go.

        To be clear. I don't actually propose to make this change, I understand that this would broke a lot of things including quite healthy scripts which use something like already mentioned

        BEGIN {s!^(\s)!./$1!,s/^/</,s/$/\0/ for @ARGV}
        Just in disagreement with your position I think that
        • this feature is not so useful
        • it's weird and error prone
        • it's make easy things harder