cwvh/pbsmake — Issue #11: proper pattern substitutions
Author: cwvh
Created: 2012-01-04 09:06:52+00:00
State: open

A '%' pattern subst. should match the left and right anchors like GNU.

%: %baz

-baz:
@echo ${pm_target_match}

`pbsmake.py -f … foo-` should match `foo-baz` and not `foo--baz`.

The following should correctly match and sub `target` with `wildcard`:

wildcard = 'foo-'
prefix, _, suffix = target.partition('%')
for p, s, w, r = zip(prefix, suffix, wildcard, reversed(wildcard)):
if p == w:
wildcard = wildcard[1:]
if s == r:
wildcard = wildcard[:-1]
target = target.replace('%', wildcard)