From 545ee0c3380b899ec104b7f7f39007b32727f85a Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Tue, 17 Jan 2017 03:36:12 +0100 Subject: [PATCH] Moved bash version detection to top and improved logic (#4578) --- .../src/main/resources/bash/client.mustache | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/bash/client.mustache b/modules/swagger-codegen/src/main/resources/bash/client.mustache index 5a11334690d..934fddcbe8c 100644 --- a/modules/swagger-codegen/src/main/resources/bash/client.mustache +++ b/modules/swagger-codegen/src/main/resources/bash/client.mustache @@ -25,6 +25,20 @@ # {{#externalDocs}}{{url}}{{/externalDocs}} # +############################################################################### +# +# Make sure Bash is at least in version 4.3 +# +############################################################################### +if ! ( (("${BASH_VERSION:0:1}" == "4")) && (("${BASH_VERSION:2:1}" >= "3")) ) \ + && ! (("${BASH_VERSION:0:1}" >= "5")); then + echo "" + echo "Sorry - your Bash version is ${BASH_VERSION}" + echo "" + echo "You need at least Bash 4.3 to run this script." + echo "" + exit 1 +fi ############################################################################### # @@ -899,14 +913,6 @@ call_{{operationId}}() { ############################################################################## -# Make sure Bash is at least in version 4.3 -if [[ ${BASH_VERSION:0:1} < 4 && ${BASH_VERSION:2:1} < 3 ]]; then - echo "Sorry - your Bash version is ${BASH_VERSION}" - echo "" - echo "You need at least Bash 4.3 to run this script." - exit 1 -fi - # Check dependencies type curl >/dev/null 2>&1 || { echo >&2 "Error: You do not have 'cURL' installed."; exit 1; } type sed >/dev/null 2>&1 || { echo >&2 "Error: You do not have 'sed' installed."; exit 1; }