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

fix: Fix Incorrect sed Regular Expression Handling Update tools.sh #1962

Closed
wants to merge 1 commit into from

Conversation

0xbryer
Copy link

@0xbryer 0xbryer commented Dec 22, 2024

Description

I noticed an issue with how a regular expression was used in a sed command within the bash script. Specifically, the expression:

sed 's/go*//'  

This approach has unintended behavior because the * in sed matches zero or more occurrences of the preceding character. As a result, it removes any sequence of g and o, which might not align with the intended functionality.

To address this, I updated the code to ensure it only removes the exact prefix go at the beginning of the string:

sed 's/^go//'  

Here’s the breakdown of the fix:

  • Added ^ to anchor the match to the start of the string.
  • Adjusted the expression to match go strictly at the beginning, avoiding accidental removal of unintended sequences.

Author Checklist

This correction ensures that the script behaves as expected and only removes the go prefix where necessary.

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

@0xbryer 0xbryer requested a review from a team as a code owner December 22, 2024 12:03
Copy link

github-actions bot commented Jan 2, 2025

Marked as stale; will be closed in five days.
Cut bait or go fishing!

@github-actions github-actions bot added the stale label Jan 2, 2025
@@ -16,7 +16,7 @@ function get_gotoolchain() {
if [[ ${gotoolchain} == "" ]]; then
# determine go toolchain from go version in go.mod
if which go > /dev/null 2>&1 ; then
local_goversion=$(GOTOOLCHAIN=local go version | cut -d ' ' -f 3 | sed 's/go*//' | tr -d '\n')
local_goversion=$(GOTOOLCHAIN=local go version | cut -d ' ' -f 3 | sed 's/^go//' | tr -d '\n')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail i believe. here is output of go version command

go version go1.23.4 darwin/arm64

@github-actions github-actions bot closed this Jan 9, 2025
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.

2 participants