|
11:20
librasteve_ joined
15:27
david32 joined
16:51
david32 left
|
|||
| Geth | GD-Raw: jforget++ created pull request #2: Implementing gdImageEllipse and gdImageRectangle. |
20:32 | |
|
22:11
david7832 joined
|
|||
| david7832 | @lizmat: I've used your paths module today, feeding its outputs into a shell command like this: qqx⟨crc32 "$^f"⟩. Some of the filenames did contain a double quote, so I had to escape them first: | 23:04 | |
| for paths».subst('"', '\"') { qqx⟨crc32 "$^f" ⟩ | |||
| In fact, I should have escaped all four of <" \ ` $> | |||
| Would you consider merging a PR that adds an option to do this automatically? | |||
| I'm thinking about extending the signature like this: | |||
| sub paths( ...., :dqescape(:$doublequoteescape)) | |||
| To be used like: | |||
| for paths('/home/ds'):dqescape { qqx⟨some-command "$^f⟩ } | |||
| The reason behind this is because I think this use case is pretty common: One wants to apply shell commands to the paths and thus has to properly escape them. In bash and sh at least, double quotes are the sanest way for this, as far as I'm aware. | |||
| (Can't say for sure if I'll actually make such a PR, since it looks like I'll have to learn nqp first, but that would give me a decent goal to learn towards :) ) | |||
| lizmat | then I suggest something like :shell so we can make it depending on $*SPEC | 23:06 | |
| david7832 | good point. I suspect it's very desirable to be explicit about the quoting method; perhaps there is a solution to do both | 23:09 | |
| lizmat | otoh, it feels to me that paths should be kept as simple and fast as possible | 23:11 | |
| perhaps the documentation should be enhanced... | 23:12 | ||
| also I wonder if the IO::Spec modules contain logic for escaping? | |||
| david7832 | regarding paths: perhaps there's a way to add the option in such a way that it only really impacts the performance when it's used. | 23:18 | |
| I can definitely see why it's good to keep that module simple. However (even though on Unix we're in "you asked for it, you get it" territory) I think the fact that a builtin quoting option also protects users against accidental shell havoc carries some weight | |||
| since I think the fact is that module will be used for insertion into shell commands quite often :) | 23:19 | ||
| but I'll definitely look into IO::Spec, perhaps it is the best place for escaping logic after all | 23:20 | ||
| lizmat | don't worry about performance much: a named argument can be handled by another candidate, and thus already create a slow(er) path in that case without affecting the one without the named arg | 23:28 | |
| david7832 | Ah, very good then | 23:34 | |
| As for the signature, how about: | |||
| for paths:escapefor("'") | |||
| for paths:escapefor('single quote') | |||
| i.e. when calling it, one indicates the construct inside of which one intends to use the paths, and the actual quoting behavior then depends on $*SPEC (and potentially other system variables) | |||
| lizmat | if you want to make it convenient for shell escaping, it should do *all* the escapes for that shell | 23:36 | |
| anyways, I'll see what you come up with after some shuteye :) | 23:37 | ||
| afk& | |||
| david7832 | thanks for all the infos, good night! | ||
|
23:50
librasteve_ left
|
|||