From: Maxim Mamontov Date: Sat, 25 Oct 2014 02:13:21 +0000 (+0300) Subject: Portable sed. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/47d3bf9ab38d9db40491b0227169ec54f1707976?ds=sidebyside Portable sed. --- 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"`