Repository navigation
fix: handle empty package lists, missing Homebrew and wrong shell - #2
Merged
Merged
Conversation
- an empty `brew list` output produced a one-element array: phantom cask section, wrong total (e.g. "Total: 2" without Homebrew) - exit with a clear message when Homebrew is not installed - exit with a clear message when run with bash/sh instead of zsh (previously: "typeset: -g: invalid option") - print "No Homebrew packages installed." instead of an empty shelf - "1 package" instead of "1 packages" - reuse category_color() instead of a duplicated case statement Tests: tests/run.zsh runs the script against a fake brew (tests/bin/brew) — 17 checks, 7 of them fail on the previous version. CI runs them on macOS.
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.
First PR of a series (bug fixes → descriptions from Homebrew → installed-vs-dependencies → CLI options → README + tap). It also adds tests and CI, so every following PR is covered.
Bugs fixed
Total: 2 packages installedwith empty sectionsbrewshelf: Homebrew not found — install it from https://brew.sh, exit 1No Homebrew packages installed.bash brewshelf.shtypeset: -g: invalid optionrequires zsh — run it as 'zsh brewshelf.sh'…, exit 11 packages1 packageRoot cause of the first two:
("${(@f)$(cmd)}")turns empty output into one empty element. Unquoted(${(f)"$(cmd)"})drops it.Cleanup:
category_color()was defined but never called. The same mapping was duplicated inline, and the function is now used.Tests
zsh tests/run.zshruns the script against a fakebrew(tests/bin/brew) with a PATH that excludes the real Homebrew, so results don't depend on the machine.main, and all pass with this PR.CI
GitHub Actions on
macos-latestruns the tests on every PR and push tomain.