Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds a guard to a flag to ensure that the
eval
will produce a value. Without this change, a flag likemy-flag
will go through theeval
as$my-flag
. Since bash doesn't permit dashes in variable names, the resulting value will be-flag
. Because this is a non-zero length, the first iteration through the for loop on${e}
will set inFLAGS
, then break out. This leads to the improper result ofFLAGS
having-flag
instead of the desired value ofmy-flag
.By testing that flag will produce a value before trying
eval
, we can be sure that the first loop iteration will proceed and allow the processing of the second iteration on${flag}
(which will correctly capturemy-flag
in our example).${!flag+x}
is used for indirect variable expansion. If flag contains the name of a variable,${!flag}
will expand to the value of that variable. The +x part ensures that the expression evaluates to true if the variable exists, even if it's empty.This fixes #175.