Skip to contentSkip to conversation

configure: Add a check for the bash version

PATCH In review Thomas Huth 2 participants 3 messages Sep 25, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: Add a check for the bash version

Our scripts do not work with older versions of the bash, like the default Bash 3 from macOS (e.g. we use the "|&" operator which has been introduced in Bash 4.0). Add a check to make sure that we use at least version 4 to avoid that the users run into problems later.

---
 configure | 5 +++++
 1 file changed, 5 insertions(+)
configure +5 -0
index f930543..39b63ae 100755
@@ -1,5 +1,10 @@
 #!/usr/bin/env bash
 
+if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
+    echo "Error: Bash version 4 or newer is required for the kvm-unit-tests"
+    exit 1
+fi
+
 srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc
Signature · 1 line
2.18.2
maintainer
#1 lore raw
Quoted 16 lines · Thomas Huth

Our scripts do not work with older versions of the bash, like the default Bash 3 from macOS (e.g. we use the "|&" operator which has been introduced in Bash 4.0). Add a check to make sure that we use at least version 4 to avoid that the users run into problems later.

---
 configure | 5 +++++
 1 file changed, 5 insertions(+)
configure +0 -0
index f930543..39b63ae 100755

configure line 10

Quoted 10 lines
configure +5 -0
@@ -1,5 +1,10 @@
 #!/usr/bin/env bash
 
+if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
+    echo "Error: Bash version 4 or newer is required for the kvm-unit-tests"
+    exit 1
+fi
+
 srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc

Looks good, would you like me to apply it or do you prefer to send a pull request once you have more stuff?

Paolo

#2 lore raw
Quoted 18 lines · Paolo Bonzini
Quoted 17 lines · Thomas Huth

Our scripts do not work with older versions of the bash, like the default Bash 3 from macOS (e.g. we use the "|&" operator which has been introduced in Bash 4.0). Add a check to make sure that we use at least version 4 to avoid that the users run into problems later.

---
 configure | 5 +++++
 1 file changed, 5 insertions(+)
configure +0 -0
index f930543..39b63ae 100755
@@ -1,5 +1,10 @@
 #!/usr/bin/env bash
 
Quoted 12 lines

configure line 10

Quoted 9 lines
configure +5 -0
+if [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
+    echo "Error: Bash version 4 or newer is required for the kvm-unit-tests"
+    exit 1
+fi
+
 srcdir=$(cd "$(dirname "$0")"; pwd)
 prefix=/usr/local
 cc=gcc

Looks good, would you like me to apply it or do you prefer to send a pull request once you have more stuff?

I can put it into my next pull request.

Thomas