[X2Go-Commits] [buildscripts] 01/02: bin/{debian, ubuntu}-codename-to-version.sh: fix various shortcomings:

git-admin at x2go.org git-admin at x2go.org
Mon Jul 4 21:55:47 CEST 2016


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository buildscripts.

commit 3153ec59c323cdc2efb3d394f0e4e2f98ca28c93
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Mon Jul 4 21:42:28 2016 +0200

    bin/{debian,ubuntu}-codename-to-version.sh: fix various shortcomings:
    
      - return can only be used in functions. Switch to "exit" instead.
      - typeset -l makes the content lowercase, not the variable "local"
        (that's implied by using typeset.) Hence, drop it where
        inappropriate.
      - typeset -l is only available in BASH 4 and higher. Use it
        conditionally only.
      - Use tr to convert strings to lowercase when using a BASH version
        lower than 4.
---
 bin/debian-codename-to-version.sh |   14 +++++++++++---
 bin/ubuntu-codename-to-version.sh |   14 +++++++++++---
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/bin/debian-codename-to-version.sh b/bin/debian-codename-to-version.sh
index 8bd0384..42f497b 100755
--- a/bin/debian-codename-to-version.sh
+++ b/bin/debian-codename-to-version.sh
@@ -29,10 +29,18 @@ unset CDPATH
 # The return code is either 0, iff mapping was successful,
 # or 1 if the code name is unknown and mapping failed.
 
-typeset -l codename
+# Where supported (BASH 4 and higher), automatically
+# lower-case the codename argument.
+if [ -n "${BASH_VERSINFO[0]}" ] && [ "${BASH_VERSINFO[0]}" -gt 3 ]; then
+	typeset -l codename
+fi
 codename="${1:?"No code name provided."}"
 
-typeset -l -i ret="0"
+if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
+	codename="$(tr '[:upper:]' '[:lower:]' <<< "${codename}")"
+fi
+
+typeset -i ret="0"
 
 case "${codename}" in
 	# The first version number is actually "fake",
@@ -79,4 +87,4 @@ case "${codename}" in
 	(*) ret="1";;
 esac
 
-return "${ret}"
+exit "${ret}"
diff --git a/bin/ubuntu-codename-to-version.sh b/bin/ubuntu-codename-to-version.sh
index 943e130..f2884cf 100755
--- a/bin/ubuntu-codename-to-version.sh
+++ b/bin/ubuntu-codename-to-version.sh
@@ -28,10 +28,18 @@ unset CDPATH
 # The return code is either 0, iff mapping was successful,
 # or 1 if the code name is unknown and mapping failed.
 
-typeset -l codename
+# Where supported (BASH 4 and higher), automatically
+# lower-case the codename argument.
+if [ -n "${BASH_VERSINFO[0]}" ] && [ "${BASH_VERSINFO[0]}" -gt 3 ]; then
+	typeset -l codename
+fi
 codename="${1:?"No code name provided."}"
 
-typeset -l -i ret="0"
+if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
+	codename="$(tr '[:upper:]' '[:lower:]' <<< "${codename}")"
+fi
+
+typeset -i ret="0"
 
 case "${codename}" in
 	# The first version number is actually "fake",
@@ -69,4 +77,4 @@ case "${codename}" in
 	(*) ret="1";;
 esac
 
-return "${ret}"
+exit "${ret}"

--
Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git


More information about the x2go-commits mailing list