Skip to content

fix(v1): validate command args before the root check (green ShellCheck CI)#2

Merged
xxvcc merged 1 commit into
mainfrom
fix/v1-shellcheck-nonroot
Jul 8, 2026
Merged

fix(v1): validate command args before the root check (green ShellCheck CI)#2
xxvcc merged 1 commit into
mainfrom
fix/v1-shellcheck-nonroot

Conversation

@xxvcc

@xxvcc xxvcc commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Problem

The ShellCheck workflow's Unit tests step (bash tests/unit.sh) has been red since v1.2.0 because it runs as the non-root runner user, while the v1 bash tool's install/uninstall/upgrade commands called need_root before parsing their arguments. So on a non-root runner:

  • install --bad exited with "please run as root" instead of install: unsupported argument: --bad
  • same for uninstall --bad
  • upgrade --url http://… --yes hit the root error before the URL-safety check, so Upgrade URL is unsafe or invalid never printed

The harness aborts on the first failing assertion, so only install showed in the CI log.

Fix

Validate arguments before the privilege check — matching how doctor already works. For upgrade, also run valid_upgrade_url before need_root so an unsafe --url is reported regardless of privilege. No behavior change when run as root.

Verification

  • tests/unit.sh passes as both root and non-root (reproduced the CI non-root env with a throwaway user).
  • bash -n temp-admin.sh tests/unit.sh and shellcheck -S warning temp-admin.sh tests/unit.sh clean.

Scope: v1 bash maintenance line only; does not touch the v2 Go code.

🤖 Generated with Claude Code

…-root)

install/uninstall/upgrade called need_root before parsing their arguments, so
on a non-root runner (GitHub Actions) `install --bad` etc. exited with the
"please run as root" error instead of the expected "unsupported argument"
message — failing tests/unit.sh (the ShellCheck workflow) since v1.2.0. Parse
and validate arguments first (as doctor already does); for upgrade also validate
the URL before need_root so an unsafe --url is reported regardless of privilege.
No behavior change when run as root.

Verified: tests/unit.sh passes as both root and non-root; bash -n and
shellcheck -S warning clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xxvcc xxvcc merged commit 895d0f6 into main Jul 8, 2026
10 checks passed
@xxvcc xxvcc deleted the fix/v1-shellcheck-nonroot branch July 8, 2026 08:18
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.

1 participant