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

Dashes and periods in flag names don't work in the Orb #175

Open
joseph-sentry opened this issue Oct 26, 2023 · 1 comment · May be fixed by #188
Open

Dashes and periods in flag names don't work in the Orb #175

joseph-sentry opened this issue Oct 26, 2023 · 1 comment · May be fixed by #188
Assignees

Comments

@joseph-sentry
Copy link
Contributor

See: #174

Two different errors happen for flags with . and - in the name.

For -:

[2023-10-26T18:11:27.831Z] ['error'] There was an error running the uploader: undefined is not a function

For .: the flag name before the . just disappears

@arthurio
Copy link

arthurio commented Dec 20, 2023

I'm facing the same issue, I instead passed -F my-flag to xtra_args (this creates a weird blank tag, don't do that) use flag names with _ instead of periods or hyphens. The issue happens with this piece of code: eval e="\$$flag", e.g.:

flag="my-flag"
eval e="\$$flag"
echo $e
-flag

mblayman added a commit to mblayman/codecov-circleci-orb that referenced this issue Feb 21, 2024
This change adds a guard to a flag to ensure that the `eval` will produce a value. Without this change, a flag like `my-flag` will go through the `eval` 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 in `FLAGS`, then break out. This leads to the improper result of FLAGS having `-flag` instead of the desired value of `my-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 capture `my-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 codecov#175.
@mblayman mblayman linked a pull request Feb 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants