Skip to content

Comments

RFC: A small potential optimization in the installation script#121

Closed
Guiorgy wants to merge 1 commit intotis24dev:mainfrom
Guiorgy:patch-1
Closed

RFC: A small potential optimization in the installation script#121
Guiorgy wants to merge 1 commit intotis24dev:mainfrom
Guiorgy:patch-1

Conversation

@Guiorgy
Copy link

@Guiorgy Guiorgy commented Feb 1, 2026

From the grep man page:

-m NUM Stop reading a file after NUM matching lines.

Instead of having grep try to pattern match the whole input and then use head -n1 to then discard everything but the first match, we could tell grep to stop after finding the first match and then discard the rest into the void (/dev/null). We need to continue to read from pipe and discard it since curl panics with error code 23 when the pipe is suddenly closed.

I run the installation script with this modification, and at least the happy path works as intended.

Alternatively, we could store the output from curl in a temporary variable and then use a here string on grep to extract the first match only: grep -m1 '"tag_name"' <<< "$response" | cut -d '"' -f4. This will also reduce the calls to external tools by one (head/cat).

From the grep man page:
    -m NUM      Stop reading a file after NUM matching lines.

The redirect of the rest of the pipe input to /dev/null is to avoid curl panicking with code 23 due to the pipe closing prematurely
@tis24dev
Copy link
Owner

tis24dev commented Feb 2, 2026

Hi, thank you for your suggestion. I have improved the situation in a different and more structured way.

This is the commit for the change: b0d1151

@Guiorgy Guiorgy closed this Feb 2, 2026
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 this pull request may close these issues.

2 participants