[gmx-developers] bad sed expression in share/template/Makefile.am

Mark Abraham Mark.Abraham at anu.edu.au
Fri Nov 13 23:46:25 CET 2009

Ake Sandgren wrote:
> On Fri, 2009-11-13 at 11:31 +1100, Mark Abraham wrote:
>> Ake Sandgren wrote:
>>> Hi!
>>> The sed in share/template/Makefile.am uses "," as separator. This is bad
>>> since LDFLAGS and others might contains things like -Wl,-rpath and other
>>> things with "," in them. "#" is usually a better choice.
>> Using "," as a sed separator seems to be standard practice with the 
>> autotools. From autoconf docs:
>> "When using sed, don't use -e except for indenting purpose. With the s 
>> command, the preferred separator is `/' unless `/' itself is used in the 
>> command, in which case you should use `,'. "
>> Wouldn't "#" get interpreted as a Makefile comment?
> Nope, it's within single-quotes.

True... but on the converse, many's the time I've been playing with 
xxFLAGS arguments and just commented out the last bunch to see the 
effect... that'll break the sed line as well.

The fundamental problem is that sed has to parse something that may or 
may not need characters escaped depending how we're calling sed. If it's 
a problem, then doing the escaping before the sed expression can be the 
way forward. Now, what separators to use with the "escape the 
parameters" regexp? :-P


> And the comment above about "/" of course also applies to "," :-)
> The problem is that there is no safe separator in sed. You could en up
> in the situation, very low probability of course but still, that ALL
> characters is used in the expression.
> One could find one by using something like
> echo "abcdef...ABC...0123...+-_:;,*?!#%&(everything in the ASCII set)" |
> tr -d `echo "$(LDFLAGS)$(...)..."` | cut -c1
> but that is kind of overkill :-)

More information about the gromacs.org_gmx-developers mailing list