in reply to To glob or not to glob

Hi haukex,

you're making a very valid point++. I sort of feel guilty here, since I must admit that I do recommend glob every now and then (though quite rarely), because it makes most things shorter and easier (especially, compared to opendir/readir, because it returns filenames with their relative paths, that's really nice), it does what I want in probably 95% of the cases. And I must further confess that, when I happen to recommend glob, I usually do not list the caveats (especially not the fourth one, which I know but would not even think of mentioning); if you write one short line to recommend to perhaps use glob for its ease in a given situation, you just can't really add four paragraphs to warn about possible issues in other situations.

To tell the truth, I usually hesitate a bit before recommending it, because of the issues that you listed, but I still think it is a very practical operator and I don't think it should be banned (at least not on *nix systems). I am happy that it removes directory entries starting with a dot (it saves me a grep with a regex), because that's exactly what I need most of the time. I also like that way it does pattern expansion to pick up the files that I'm looking for (saves another grep). Even if it's not used so often, the multi pattern expansion when there is a white space can really be handy. And I am especially happy that it returns filenames with paths, as this is very often what I want to have. These are quite significant advantages IMHO.

Yet, I also agree with the caveats you're mentioning. Should we then throw the baby out with the bath water? I'm not quite sure, but I would tend to think we shouldn't. But, clearly, it should be used only in well defined situations. Should we recommend it? Or stop recommending it? I don't know.