crowell / modpagespeed_tmp

Automatically exported from code.google.com/p/modpagespeed
Apache License 2.0
0 stars 0 forks source link

remove whole line sed pattern not working #632

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. make -C install staging_except_module

What is the expected output? What do you see instead?

options marked as "remove whole line" removed from output file

What version of the product are you using (please check X-Mod-Pagespeed
header)?
1.3.25.3

On what operating system?
PLD Linux

Which version of Apache?
2.2.23

Which MPM?
prefork

Sed version:
4.4.2

the problem is that sed does not match \n as newline, and therefore removing a 
line does not work:

ifeq ($(ALL_DIRECTIVES_TEST),1)
  # remove prefix
  ALL_DIRECTIVES_TEST_SED_PATTERN=^\#ALL_DIRECTIVES
else
  # remove whole line
  ALL_DIRECTIVES_TEST_SED_PATTERN=^\#ALL_DIRECTIVES.*\n
endif

echo '#ALL_DIRECTIVES' | sed -e "s@^#ALL_DIRECTIVES.*\n@@"
echo '#ALL_DIRECTIVES' | sed -e 's@^#ALL_DIRECTIVES.*\n@@'

results still "#ALL_DIRECTIVES" present in output.

perhaps it's not portable? anyway, to delete a matching line such code works 
better (and documented):

echo '#ALL_DIRECTIVES' | sed -e "/^#ALL_DIRECTIVES.*/d"
echo '#ALL_DIRECTIVES' | sed -e '/^#ALL_DIRECTIVES.*/d'

Original issue reported on code.google.com by elan.ruu...@gmail.com on 2 Mar 2013 at 11:49

GoogleCodeExporter commented 9 years ago
proposed patch, uses /PATTERN/d to delete a line

Original comment by elan.ruu...@gmail.com on 2 Mar 2013 at 12:21

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by jmara...@google.com on 4 Mar 2013 at 7:47

GoogleCodeExporter commented 9 years ago
for 1.5.27.2 such replace needed in install/Makefile:

s,\^\\#\([A-Z_]*\)\.\*\\n,/^\#\1/d,

Original comment by elan.ruu...@gmail.com on 3 May 2013 at 12:30

Attachments:

GoogleCodeExporter commented 9 years ago
for 1.5.27.2 such replace needed in install/Makefile, so in vim i typed:

update pattern to remove prefixes
:%s,\^\\#\([A-Z_]*\)$,s/&//,

update pattern to remove whole lines:
:%s,\^\\#\([A-Z_]*\)\.\*\\n,/^\\#\1/d,

and some manual changes in the place where macros being used

Original comment by elan.ruu...@gmail.com on 3 May 2013 at 1:18

Attachments:

GoogleCodeExporter commented 9 years ago
this is still actual. will be submitting patch for 1.8.31.5 soon

Original comment by elan.ruu...@gmail.com on 14 Dec 2014 at 2:12

GoogleCodeExporter commented 9 years ago
third pattern added:

:%s#-e "s@\$(\([A-Z_]*_PATTERN\))@@"#-e "$(\1)"#

Original comment by elan.ruu...@gmail.com on 14 Dec 2014 at 2:20

Attachments: