William L. Thomson Jr. wrote: > On Sat, 2007-11-10 at 18:36 +0100, Bo Ørsted Andresen wrote: >> On Sat, Nov 10, 2007 at 11:51:37AM +0100, Krzysiek Pawlik wrote: >> > It's purpose is to remove the ${D} from makefile, additionally ${D} is >> > in single quotes, so it will not be expanded - is it a bug in repoman >> > check? >> >> What ${D} ? I see none in that makefile. Which is why I think a patch >> would be better in this case. A patch would actually tell you when half >> of the substitutions don't match anything... I think this is a point >> worth making even if it doesn't change your point. > > I have kinda gone back and forth between patches and sed. While I agree > patches are better since they fail to apply at times. Sed stuff can be > more portable amongst revisions, as I have found with maintaining assp. > Where the patch grew to the point it had to be mirrored :(. > > Now I know some will scream, puke, throw up in their mouth, and so on. > But seems like sed should have an OPTIONAL argument or etc to tell sed > to either fail if it can't make the change anywhere. And/or keep/output > a count of how many things were modified. > ed does this by default (which can make it trickier) -- if a standard search and replace doesn't match, it's considered an error. I appreciate ed isn't currently part of system set, but imo it should be, since it's specified in posix. A workaround is grep -q, eg:
if grep -qF '${D}' file; then sed -i '#\${D}##' file fi (You need to escape $ in a regex or it'll be treated as end marker.) This is more useful in cases where you need to know what is in the file for whatever reason (eg grep -q '^FEATURES="[^"]*-blah' /etc/make.conf [1]), since the sed will not affect the file if there is no match. Of course, repoman still needs to ignore stuff in single quotes. [1] if ! grep -qF sandbox < <(portageq envvar FEATURES); then .. (for example) is safer for general case. -- [EMAIL PROTECTED] mailing list