From: Amadeusz Żołnowski <[email protected]>
awk doesn't have the -i option like sed and if editing file in place is
desired, additional steps are required. eawk uses tmp file to make it
look to the caller editing happens in place.
---
eclass/eutils.eclass | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/eclass/eutils.eclass b/eclass/eutils.eclass
index dbedffe..e331f1b 100644
--- a/eclass/eutils.eclass
+++ b/eclass/eutils.eclass
@@ -20,6 +20,19 @@ _EUTILS_ECLASS=1
inherit multilib toolchain-funcs
+# @FUNCTION: eawk
+# @USAGE: <file> <args>
+# @DESCRIPTION:
+# Edit file <file> in place with awk. Pass all arguments following <file> to
+# awk.
+eawk() {
+ local f="$1"; shift
+ local tmpf="$(emktemp)"
+
+ cat "${f}" >"${tmpf}" || return 1
+ awk "$@" "${tmpf}" >"${f}"
+}
+
# @FUNCTION: eqawarn
# @USAGE: [message]
# @DESCRIPTION:
--
2.8.2