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

Prevent Sentry from attempting to access unbound variables #1415

Merged
merged 2 commits into from Jan 4, 2023

Conversation

LeonMelis
Copy link
Contributor

Bash has a nifty feature set -u to error on unbound variables. This is also trappable (like with set -e), so Sentry can catch this.

However, Sentry itself may attempt to access arguments via $1 and $2, which may not be set, which will trigger a bash error if set -u is used. This will create an error output: ./my_script.sh: line 42: $1: unbound variable.

The proposed fix here will check for existence of $1...$n via the argument count $#, without accessing $1...$n, making it possible to use Sentry for bash scripts with set -u

@github-actions
Copy link

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@LeonMelis
Copy link
Contributor Author

Maybe someone from Sentry should have a look at this, before my PR is closed automatically due to inactivity...

@kamilogorek
Copy link
Contributor

@LeonMelis I missed that one as I'm on vacation the whole of December, will take a look at it after the new year. Cheers.

@kamilogorek
Copy link
Contributor

Makes perfect sense, thanks!

@kamilogorek kamilogorek enabled auto-merge (squash) January 4, 2023 10:28
Bash has a nifty feature `set -u` to error on unbound variables. This is also trappable (like with `set -e`), so Sentry can catch this.

However, Sentry itself may attempt to access arguments via `$1` and `$2`, which may not be set, which will trigger a bash error if `set -u` is used. This will create an error output: `./my_script.sh: line 42: $1: unbound variable`.

The proposed fix here will check for existence of `$1...$n` via the argument count `$#`, without accessing `$1...$n`, making it possible to use Sentry for bash scripts with `set -u`
@kamilogorek kamilogorek merged commit 401b91d into getsentry:master Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants