Skip to content

Commit 4313a5b

Browse files
Ryan Moellerbehlendorf
authored andcommitted
Detect if sed supports --in-place
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}. Reviewed-by: Chris Dunlop <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #9463
1 parent 08f530c commit 4313a5b

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

cmd/arcstat/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = arcstat
88
#
99
if USING_PYTHON_2
1010
install-exec-hook:
11-
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
11+
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
1212
$(DESTDIR)$(bindir)/arcstat
1313
endif

cmd/dbufstat/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ dist_bin_SCRIPTS = dbufstat
88
#
99
if USING_PYTHON_2
1010
install-exec-hook:
11-
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
11+
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
1212
$(DESTDIR)$(bindir)/dbufstat
1313
endif

config/always-sed.m4

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
dnl #
2+
dnl # Set the flags used for sed in-place edits.
3+
dnl #
4+
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SED], [
5+
ac_inplace=""
6+
AC_CACHE_CHECK([for sed --in-place], [ac_cv_path_SED],
7+
[AC_PATH_PROGS_FEATURE_CHECK([SED], [sed],
8+
[[tmpfile=$(mktemp)
9+
echo foo > $tmpfile
10+
$ac_path_SED --in-place 's#foo#bar#' $tmpfile \
11+
&& ac_cv_path_SED=$ac_path_SED
12+
rm $tmpfile]],
13+
[ac_inplace="-i ''"])])
14+
AS_IF([test "x$ac_inplace" = "x"], [ac_inplace="--in-place"])
15+
AC_SUBST([ac_inplace])
16+
])

config/zfs-build.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
164164
ZFS_AC_CONFIG_ALWAYS_ARCH
165165
ZFS_AC_CONFIG_ALWAYS_PYTHON
166166
ZFS_AC_CONFIG_ALWAYS_PYZFS
167+
ZFS_AC_CONFIG_ALWAYS_SED
167168
])
168169

169170
AC_DEFUN([ZFS_AC_CONFIG], [

tests/test-runner/bin/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dist_pkgdata_SCRIPTS = \
99
#
1010
if USING_PYTHON_2
1111
install-data-hook:
12-
sed --in-place 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
12+
sed ${ac_inplace} -e 's|^#!/usr/bin/env python3|#!/usr/bin/env python2|' \
1313
$(DESTDIR)$(pkgdatadir)/test-runner.py \
1414
$(DESTDIR)$(pkgdatadir)/zts-report.py
1515
endif

0 commit comments

Comments
 (0)