ohmu / poni

poni - a systems configuration software
http://melor.github.com/poni/
Apache License 2.0
44 stars 18 forks source link

Regexps considered harmful; documentation is sloppy about regexps #6

Open tv42 opened 13 years ago

tv42 commented 13 years ago

I hope you'll reconsider using regexps for matching identifiers on the command line. It makes it too easy for admins to shoot themselves in the foot. To prove my point, the docs at http://melor.github.com/poni/template-variables.html use an unanchored $find("webshop/frontend"), which would match e.g. webshop/frontendforsomethingelse.

I'd be much happier if Poni used globs, because they have way fewer magic characters, and those tend to stick out more. I've seen people hurt themselves even with the periods in DNS domain names, when used directly as a regexp pattern. You could always provide a --regex option for when the power is needed.

melor commented 13 years ago

There are a two separate variables here: full string matching vs. partial string matching and the pattern matching syntax used (regex vs. glob).

I believe you are right with your concerns and I have actually been already thinking about changing the default to be strict full path matching for most commands and template functions. Using globs did not occur to me as I was only aware of the "glob" module, which does not provide generic pattern matching functionality, just globbing file paths. Now that I dug a bit deeper and found "fnmatch", I see that using it would be rather trivial for this purpose.

However, there are already multiple souls whose wrath will unleash over me if I change the default behavior, so making this change happen will need some careful coordination.

Issue in consideration, no ETA yet.