From dcee211388082867f13991c50a554eb22b9a23cb Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Mon, 6 Apr 2009 14:13:06 +0000 Subject: [PATCH] Update shell files to use /bin/bash and POSIX . bash's earlier problems with subshells running scripts starting #!/bin/bash seem to be solved, so explicitly mark all scripts as requiring bash. Furthermore, change all source built-ins to prefix the path with "./" as required by POSIX. Together these changes should stop further problems with changes of source built-in semantics in future. --- create.sh | 4 ++-- install-symlinks.sh | 2 +- scripts/config-printflags.sh | 2 +- scripts/module-create.sh | 8 ++++---- scripts/release.sh | 2 +- scripts/version.sh | 14 +++++++------- skel/make.sh | 8 ++++---- skel/run-test.sh | 8 ++++---- update.sh | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/create.sh b/create.sh index a2da766..8cac62d 100755 --- a/create.sh +++ b/create.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # (c)2009, Laurence Withers. Released under the GNU GPL. See file # COPYING for details. @@ -52,7 +52,7 @@ then echo "Edit this file, and then re-run the build process." exit 1 fi -do_cmd source ${LWBUILDRC} || exit 1 +do_cmd source "${LWBUILDRC}" || exit 1 diff --git a/install-symlinks.sh b/install-symlinks.sh index aea147c..9ac1c83 100755 --- a/install-symlinks.sh +++ b/install-symlinks.sh @@ -45,7 +45,7 @@ case "$#" in ;; esac -source ${SCRIPT_ROOT}/skel/scripts/functions.sh || exit 1 +source "${SCRIPT_ROOT}/skel/scripts/functions.sh" || exit 1 cd ${PROJECT_ROOT} if [ -L scripts/module-create.sh ] diff --git a/scripts/config-printflags.sh b/scripts/config-printflags.sh index 7919706..0f8f82c 100755 --- a/scripts/config-printflags.sh +++ b/scripts/config-printflags.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # lw-build-system/scripts/config-printflags.sh # # (c)2009, Laurence Withers . diff --git a/scripts/module-create.sh b/scripts/module-create.sh index d94a63d..f816362 100755 --- a/scripts/module-create.sh +++ b/scripts/module-create.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # lw-build-system/scripts/module-create.sh # # (c)2009, Laurence Withers, . @@ -19,7 +19,7 @@ cd $(dirname $(pwd)) P=$(basename $(pwd)) TOP=$(pwd) [ -z "${VERBOSE}" ] && VERBOSE="0" -source scripts/functions.sh || exit 1 +source "./scripts/functions.sh" || exit 1 @@ -62,7 +62,7 @@ get_cname() { # for each argument X, it will replace @X@ with ${X} do_parameter_subst() { CNAME=$(get_cname ${NAME}) - do_cmd source ~/.lwbuildrc || exit 1 + do_cmd source "~/.lwbuildrc" || exit 1 for param in P NAME CNAME AUTHOR EMAIL VIM_MODELINE KATE_MODELINE $@ do do_cmd_redir sedscript echo "s,@${param}@,${!param},g" || exit 1 @@ -113,7 +113,7 @@ do_cmd cd src/${NAME} || cleanup do_cmd rm instantiate || cleanup do_cmd_redir .params echo "${MODULE_PARAMS}" || cleanup -( source ../../${TEMPLATE}/instantiate ) || cleanup +( source "../../${TEMPLATE}/instantiate" ) || cleanup print_success "Module instantiated" grep -r "@TODO@" . diff --git a/scripts/release.sh b/scripts/release.sh index c57f30e..6566bdc 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # lw-build-system/scripts/release.sh # # (c)2009, Laurence Withers, . diff --git a/scripts/version.sh b/scripts/version.sh index afdaa41..79f4b8f 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # lw-build-system/scripts/version.sh # # (c)2009, Laurence Withers . @@ -43,32 +43,32 @@ edit_versions() { } bump_major() { - source version + source "./version" edit_versions "version" "VERMAJOR" "$[${VERMAJOR} + 1]" "VERMINOR" "0" "VERMICRO" "0" } bump_minor() { - source version + source "./version" edit_versions "version" "VERMINOR" "$[${VERMINOR} + 1]" "VERMICRO" "0" } bump_micro() { - source version + source "./version" edit_versions "version" "VERMICRO" "$[${VERMICRO} + 1]" } bump_somajor() { - source src/$1/soversion + source "./src/$1/soversion" edit_versions "src/$1/soversion" "SOMAJOR" "$[${SOMAJOR} + 1]" "SOMINOR" "0" "SOMICRO" "0" } bump_somicro() { - source src/$1/soversion + source "./src/$1/soversion" edit_versions "src/$1/soversion" "SOMICRO" "$[${SOMICRO} + 1]" } do_tag() { - source version + source "./version" git tag "${VERMAJOR}.${VERMINOR}.${VERMICRO}" } diff --git a/skel/make.sh b/skel/make.sh index 96c5e9f..fa47a76 100755 --- a/skel/make.sh +++ b/skel/make.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # @P@/make.sh # # (c)2009, @AUTHOR@, <@EMAIL@>. @@ -15,19 +15,19 @@ then echo "Configuration file not found???" exit 1 fi -source "config" # don't fail on error, since last command in config might return false +source "./config" # don't fail on error, since last command in config might return false # Get version information -source version || exit 1 +source "./version" || exit 1 VERSION="${VERMAJOR}.${VERMINOR}.${VERMICRO}" # Get standard functions [ -z "${VERBOSE}" ] && VERBOSE="0" -source scripts/functions.sh || exit 1 +source "./scripts/functions.sh" || exit 1 # List of directories which will be emptied by clean. diff --git a/skel/run-test.sh b/skel/run-test.sh index c25d7cc..0933e8e 100755 --- a/skel/run-test.sh +++ b/skel/run-test.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # @P@/test.sh # # (c)2009, @AUTHOR@, <@EMAIL@>. @@ -33,10 +33,10 @@ print_tests() { echo "---------------------------------------------------------------------" for EXE in obj/tests/* do - [ -x ${EXE} ] || continue - NAME=$(echo ${EXE} | sed 's,obj/tests/,,') + [ -x "${EXE}" ] || continue + NAME="$(echo "${EXE}" | sed 's,obj/tests/,,')" echo -ne "${NAME}\t" - LD_LIBRARY_PATH="obj" ${EXE} --print-summary + LD_LIBRARY_PATH="obj" "${EXE}" --print-summary done } diff --git a/update.sh b/update.sh index 175bdbd..3fbf4d5 100755 --- a/update.sh +++ b/update.sh @@ -33,7 +33,7 @@ cd ${X} cd $(dirname $0) || exit 1 SCRIPT_ROOT=$(pwd) -source skel/scripts/functions.sh || exit 1 +source "./skel/scripts/functions.sh" || exit 1 do_cmd cd ${PROJECT_ROOT} || exit 1