summaryrefslogtreecommitdiff
path: root/scripts/include/common.sh
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-01-24 20:50:56 +0300
committerAndrei Karas <akaras@inbox.ru>2017-01-24 21:02:37 +0300
commitd5810b8baee3a3670210e01535485543aab3d274 (patch)
treee58e88a97c219287d51a2dfa86f9e4a4ea8adcd5 /scripts/include/common.sh
parent508999bc2d58668ccc55248f0c319ee866f71c15 (diff)
downloadspm-d5810b8baee3a3670210e01535485543aab3d274.tar.gz
spm-d5810b8baee3a3670210e01535485543aab3d274.tar.bz2
spm-d5810b8baee3a3670210e01535485543aab3d274.tar.xz
spm-d5810b8baee3a3670210e01535485543aab3d274.zip
Add some more error checks and escapes.
Diffstat (limited to 'scripts/include/common.sh')
-rw-r--r--scripts/include/common.sh33
1 files changed, 18 insertions, 15 deletions
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 $?
}