RFC: A small potential optimization in the installation script#121
Closed
Guiorgy wants to merge 1 commit intotis24dev:mainfrom
Closed
RFC: A small potential optimization in the installation script#121Guiorgy wants to merge 1 commit intotis24dev:mainfrom
Guiorgy wants to merge 1 commit intotis24dev:mainfrom
Conversation
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
Owner
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
From the grep man page:
Instead of having grep try to pattern match the whole input and then use
head -n1to 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 sincecurlpanics with error code23when 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
curlin 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).