-
-
Notifications
You must be signed in to change notification settings - Fork 41
Lower bash support from 3.2 to 3.0 #493
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
base: main
Are you sure you want to change the base?
Conversation
src/runner.sh
Outdated
| if [[ -n "$provider_output" ]]; then | ||
| local line | ||
| while IFS=" " read -r line; do | ||
| provider_data+=("$line") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable assignments of the form var+=rhs and arr+=(...) don't exist in Bash 3.0. It was introduced in Bash 3.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lines 50 and 244: local name=(...) creates a scalar variable local name="(...)" in Bash 3.0. It doesn't create an array.
lines 53, 124, 306, and 326: Loop variables i, fn, and line are leaked.
| additional_new_lines=$(grep -o '\\n' <<< "$input_str" | wc -l | tr -d '[:blank:]') | ||
| additional_new_lines=$(echo "$input_str" | grep -o '\\n' | wc -l | tr -d '[:blank:]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this change try to fix? <<< "$input_str" works in Bash 3.0.
src/runner.sh
Outdated
| set -- "$annotation_result" | ||
| revs="$1" | ||
| its="$2" | ||
| max_ms="$3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work. The "$annotation_result" will not be split.
In the first place, what is the background of rewriting read -r vars... <<< str?
| local eval_pattern='^eval' | ||
| local alias_pattern='^alias' | ||
|
|
||
| if [[ "$cmd" =~ ^eval ]]; then | ||
| if [[ "$cmd" =~ $eval_pattern ]]; then | ||
| eval "${cmd#eval }" &> /dev/null | ||
| elif [[ "$(command -v "$cmd")" =~ ^alias ]]; then | ||
| elif [[ "$(command -v "$cmd")" =~ $alias_pattern ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many cases of rewriting the regex matching this way, but this can simply be solved by defining a utility function like function regex_match() { [[ $1 =~ $2 ]]; }. Then, you can write the regular expressions inline as regex_match "$cmd" '^eval' or regex_match "$(command -v "$cmd")" '^alias'. This works in all cases of bash <= 3.1, bash >= 3.2, and bash >= 3.2 with shopt -s compat31.
Conflicts: CHANGELOG.md src/runner.sh src/test_doubles.sh
390bff0 to
96ec56f
Compare
π Description
Closes: #468 by @akinomyoga
Right now, the min supported version is bash 3.2
π Changes
β To-do list
CHANGELOG.mdto reflect the new feature or fix