From f2ae0a2fdd20981164c1a10b0be4c354234610b0 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 8 Oct 2013 16:29:15 +0200 Subject: [PATCH] lib.sh: Add sed_i() compatibility function. --- lib.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib.sh b/lib.sh index 204a8e9..7b76a7c 100644 --- a/lib.sh +++ b/lib.sh @@ -50,6 +50,21 @@ installed_path() { ) } +# Usage: sed_i ... +# +# Uses .tmp as temporary file. sed -i is not compatible due to different +# implementations. +sed_i() { + # Get last argument. + last= + for x; do + last="$x" + done + + sed "$@" >"$last".tmp + mv "$last".tmp "$last" +} + # Print the current OS. The following OS are supported at the moment: # - Debian (debian) # - Gentoo (gentoo) -- 2.43.2