From 47d3bf9ab38d9db40491b0227169ec54f1707976 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Sat, 25 Oct 2014 05:13:21 +0300 Subject: [PATCH] Portable sed. --- functest/functions | 5 +++++ functest/test.sh | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/functest/functions b/functest/functions index 51a1fd32..a90b9dcd 100644 --- a/functest/functions +++ b/functest/functions @@ -40,3 +40,8 @@ count() printf "$RES" fi } + +subst() +{ + sed -i "s|$1|$2|g" "$3" 2> /dev/null || sed -i "" "s|$1|$2|g" "$3" +} diff --git a/functest/test.sh b/functest/test.sh index 921fa3f2..84816ef4 100755 --- a/functest/test.sh +++ b/functest/test.sh @@ -2,6 +2,8 @@ BASEPATH=$1 +source `dirname $0`/functions + if [ "$BASEPATH" == "" ] then printf "Usage: $0 \n" @@ -36,8 +38,8 @@ then GROUP=wheel fi -sed -i "" "s|-STG-PATH-|$STGPATH|g" "$STGPATH/stargazer.conf" -sed -i "" "s|-STG-GROUP-|$GROUP|g" "$STGPATH/stargazer.conf" +subst "-STG-PATH-" "$STGPATH" "$STGPATH/stargazer.conf" +subst "-STG-GROUP-" "$GROUP" "$STGPATH/stargazer.conf" CURPATH=`pwd` LOGFILE="$CURPATH/"`date "+%Y-%m-%d-%H%M%S.console.log"` -- 2.44.2