Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

remove whole line sed pattern not working #632

Open
GoogleCodeExporter opened this issue Apr 6, 2015 · 6 comments
Open

remove whole line sed pattern not working #632

GoogleCodeExporter opened this issue Apr 6, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant