[Geany-Devel] Placeholder replacement in (build) commands

Dimitar Zhekov dimitar.zhekov at xxxxx
Mon Apr 6 18:35:26 UTC 2015


Hi,

Attached is a test program which does the following:

1. Expands an array of struct Placeholder { c, rep } in one step, to 
avoid the current collisions where expanded text may contain %x which is 
then interpreted as a placeholder.

It would be a shame not to include this.

2. Replaces %% with a literal %.

This is a logical thing to have...

3. Quotes any text between %" %" natively.
(Rules 1 and 2 apply identically to the text inside %" %")

*This may be easily removed from the expansion.*

Pros:
- Very unlikely to break the current user commands.
- bash quoting support for Windows, search and tools:
	bash -c 'echo "$0" "$1" "$2"' echo %"foo"'bar%" qux
	echo foo"'bar qux
- Simple to implement and understand. Contrary to the grim predictions, 
it's only ~35 lines, even considering that the expansion may be merged 
in a single function without it.

Cons:
- Uncommon quoter. All good quotes are already taken. :)
- With " ' and %" you can shoot yourself in the foot. Well, one can 
easily do that with shell by specifying $1 or "$CFLAGS", right?

I can propose rules for verifying the existing user commands, fixing 
some of them and making suggestions for others, and for verifying the 
new commands entered by the user to some extent. But if we don't like %" 
I'd skip that part.

4. Defines utils_quote_natively(), which quotes text natively. It will 
be good to quote at least --include=filespec under Windows, where the 
child is responsible for the filename expansion.

--
E-gards: Jimmy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quote.zip
Type: application/octet-stream
Size: 2567 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20150406/9ea299d6/attachment.obj>


More information about the Devel mailing list