Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bash] Improve Bash version detection #4543

Closed
bkryza opened this issue Jan 12, 2017 · 1 comment
Closed

[Bash] Improve Bash version detection #4543

bkryza opened this issue Jan 12, 2017 · 1 comment

Comments

@bkryza
Copy link
Contributor

bkryza commented Jan 12, 2017

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 -h
Steps 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.

@wing328
Copy link
Contributor

wing328 commented Jan 17, 2017

Closed via #4578

@wing328 wing328 closed this as completed Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants