From d5810b8baee3a3670210e01535485543aab3d274 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Jan 2017 20:50:56 +0300 Subject: Add some more error checks and escapes. --- scripts/include/common.sh | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'scripts/include') diff --git a/scripts/include/common.sh b/scripts/include/common.sh index 26ae83f..9c6033f 100644 --- a/scripts/include/common.sh +++ b/scripts/include/common.sh @@ -3,7 +3,7 @@ function check_error { if [ "$1" != 0 ]; then echo "Error detected" - exit $1 + exit "$1" fi } @@ -67,43 +67,44 @@ function common_run_package { } function common_use_package { - cd ${scriptsdir} + cd "${scriptsdir}" check_error $? export envfile="../env/run${package}.sh" - echo "#!/bin/bash" >${envfile} + echo "#!/bin/bash" >"${envfile}" check_error $? - echo "" >>${envfile} + echo "" >>"${envfile}" echo "package_use" package_use check_error $? - echo "\$*" >>${envfile} + echo "\$*" >>"${envfile}" check_error $? - chmod 0755 ${envfile} + chmod 0755 "${envfile}" check_error $? } function env_path { - echo "export PATH=${bindir}/$1:\$PATH" >>${envfile} + echo "export PATH=${bindir}/$1:\$PATH" >>"${envfile}" check_error $? } function env_lib_library_path { - echo "export LD_LIBRARY_PATH=${bindir}/$1:\$LD_LIBRARY_PATH" >>${envfile} + echo "export LD_LIBRARY_PATH=${bindir}/$1:\$LD_LIBRARY_PATH" >>"${envfile}" check_error $? } function env_pkg_config_path { - echo "export PKG_CONFIG_PATH=${bindir}/$1:\$PKG_CONFIG_PATH" >>${envfile} + echo "export PKG_CONFIG_PATH=${bindir}/$1:\$PKG_CONFIG_PATH" >>"${envfile}" check_error $? } function env_man { - echo "export MANPATH=${bindir}/$1:\$MANPATH" >>${envfile} + echo "export MANPATH=${bindir}/$1:\$MANPATH" >>"${envfile}" check_error $? } function run_autoreconf { cd "${srcdir}" + check_error $? echo "make distclean" make distclean echo "autoreconf $*" @@ -113,14 +114,16 @@ function run_autoreconf { function run_configure { cd "${builddir}" - echo "configure --prefix="${bindir}" $*" + check_error $? + echo "configure --prefix=\"${bindir}\" $*" "$srcdir"/configure --prefix="${bindir}" $* check_error $? } function run_cmake { cd "${builddir}" - echo "cmake -DCMAKE_INSTALL_PREFIX:PATH="${bindir}" "$srcdir" $*" + check_error $? + echo "cmake -DCMAKE_INSTALL_PREFIX:PATH=\"${bindir}\" \"$srcdir\" $*" cmake -DCMAKE_INSTALL_PREFIX:PATH="${bindir}" "$srcdir" $* check_error $? } @@ -139,13 +142,13 @@ function run_make_install { function run_git_clone { echo "clone git repository $1" - git clone $1 "../src/${package}" + git clone "$1" "../src/${package}" check_error $? } function run_hg_clone { echo "clone hg repository $1" - hg clone $1 "../src/${package}" + hg clone "$1" "../src/${package}" check_error $? } @@ -168,7 +171,7 @@ function run_hg_switch_branch { export srcbranch="$1" fi echo "hg update ${srcbranch}" - hg update ${srcbranch} + hg update "${srcbranch}" check_error $? } -- cgit v1.2.3-70-g09d2