-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Milestone
Description
Description
Improve error message when executing the script with older versions of Bash.
Swagger-codegen version
2.2.0-SNAPSHOT
Swagger declaration file content or url
This bug is independent of any particular Swagger definition.
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l bash -o output/bash -c modules/swagger-codegen/src/test/resources/2_0/bash-config.json
bash output/bash/petstore-cli -hSteps to reproduce
Execute the generated script against a Bash with version <4.3
Currently the output is:
output/bash/petstore-cli: line 133: getOrderById:::orderId: syntax error in expression (error token is ":::orderId")
output/bash/petstore-cli: line 134: placeOrder:::body: syntax error in expression (error token is ":::body")
output/bash/petstore-cli: line 135: createUser:::body: syntax error in expression (error token is ":::body")
output/bash/petstore-cli: line 136: createUsersWithArrayInput:::body: syntax error in expression (error token is ":::body")
output/bash/petstore-cli: line 137: createUsersWithListInput:::body: syntax error in expression (error token is ":::body")
output/bash/petstore-cli: line 138: deleteUser:::username: syntax error in expression (error token is ":::username")
output/bash/petstore-cli: line 139: getUserByName:::username: syntax error in expression (error token is ":::username")
output/bash/petstore-cli: line 140: loginUser:::username: syntax error in expression (error token is ":::username")
output/bash/petstore-cli: line 141: loginUser:::password: syntax error in expression (error token is ":::password")
output/bash/petstore-cli: line 142: updateUser:::username: syntax error in expression (error token is ":::username")
output/bash/petstore-cli: line 143: updateUser:::body: syntax error in expression (error token is ":::body")
output/bash/petstore-cli: line 150: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
output/bash/petstore-cli: line 198: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
Sorry - your Bash version is 3.2.57(1)-release
You need at least Bash 4.3 to run this script.Suggest a Fix
Move Bash version check to run at the beginning of the script.
In practice this issue is typical on MacOS, where the system Bash is at version 3, in order to use the generated scripts on mac it is necessary to install the latest Bash using Homebrew.