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

Running whatever * while not knowing what * expands to

I always felt safe running grep something *, can you enlighten me how it can be dangerous?

or what whatever does

in this case question is how whatever is implemented

It's like saying "let's turn all Toyotas into bumper cars

It's like saying let's equip every Toyota with safety belts.

Replies are listed 'Best First'.
Re^7: magic-diamond <> behavior -- WHAT?!
by JavaFan (Canon) on Oct 28, 2009 at 14:45 UTC
    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?

      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.