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(Makefile): defensively validate scoop output path #1255

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

xudyang1
Copy link
Contributor

scoop prefix package on Git Bash returns 0 and writes error to stdout even if scoop does not find the package. (ScoopInstaller/Scoop#6228)

Both #1252 and this change will work if future scoop returns 1 for unknown package


#1252 will fail when the followings happen:

  1. scoop still returns 0 for unknown package AND
  2. grep -v 'Could not find app path for' fails by
    2.1. scoop changes error message of scoop prefix package, OR
    2.2. scoop prefix neovim returns a path that contains Could not find app path for (very rare)

The following change enables defensive path validation against the output. Works on either forward slash or backslash as path separator.

-               if (scoop prefix neovim | grep -v 'Could not find app path for') >/dev/null 2>&1; then \
+               if (scoop prefix neovim | grep '^[A-Z]:[/\\]') >/dev/null 2>&1; then \

@xudyang1 xudyang1 force-pushed the refactor/better-grep branch from a2f36fc to d07c7b0 Compare November 12, 2024 02:46
@xudyang1 xudyang1 force-pushed the refactor/better-grep branch from d07c7b0 to b72199d Compare November 12, 2024 02:50
@L3MON4D3
Copy link
Owner

Ahh I see, this should be more safe 👍
TY!!

@L3MON4D3 L3MON4D3 merged commit 659c447 into L3MON4D3:master Nov 12, 2024
4 checks passed
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