-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Detect if sed supports --in-place #9463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I had previously closed a PR for this intending to detect and use GNU sed instead, but I'm reopening it to solve the immediate problems. Making the build depend on GNU sed can be done on top of these changes at a later time. |
Not all versions of sed have the --in-place flag. Detect support for the flag during ./configure and provide a fallback mechanism for those systems where sed's behavior differs. The autoconf variable ${ac_inplace} can be used to choose the correct flags for editing a file in place with sed. Replace violating usages in Makefile.am with ${ac_inplace}. Signed-off-by: Ryan Moeller <[email protected]>
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat | |||
# | |||
if USING_PYTHON_2 | |||
install-exec-hook: | |||
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \ | |||
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \ | |||
$(DESTDIR)$(bindir)/arcstat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the fallback mechanism? This looks like, if ${ac_inplace}
is empty, it's just going to print the modified arcstat
to stdout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-i ''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes - sorry, I mis-read the patch as --in-place
vs nothing, rather than --in-place
vs -i
.
Codecov Report
@@ Coverage Diff @@
## master #9463 +/- ##
==========================================
- Coverage 79.27% 79.06% -0.21%
==========================================
Files 414 414
Lines 123635 123635
==========================================
- Hits 98009 97754 -255
- Misses 25626 25881 +255
Continue to review full report at Codecov.
|
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat | |||
# | |||
if USING_PYTHON_2 | |||
install-exec-hook: | |||
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \ | |||
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \ | |||
$(DESTDIR)$(bindir)/arcstat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes - sorry, I mis-read the patch as --in-place
vs nothing, rather than --in-place
vs -i
.
Motivation and Context
Not all implementations of sed have the --in-place flag. The build system fails on these systems.
#9206 accidentally added one of the changes to the top level Makefile.am that should have been in this PR. This brings in the rest of the changes, fixing the dist-hook target.
Description
Detect support for the flag during ./configure and provide a fallback mechanism for those systems where sed's behavior differs. The autoconf variable ${ac_inplace} can be used to choose the correct flags for editing a file in place with sed.
Replace violating usages in Makefile.am with ${ac_inplace}.
How Has This Been Tested?
We have tested builds with this change on several distributions of Linux and on FreeBSD.
Types of changes
Checklist:
Signed-off-by
.