Skip to content

fix(argument): handle login-shell invocation names safely - #61

Merged
zhang-hongjie merged 1 commit into
masterfrom
fix/argument-login-shell-invocation
Oct 18, 2026
Merged

zhang-hongjie merged 1 commit into
masterfrom
fix/argument-login-shell-invocation

Conversation

@zhang-hongjie

Copy link
Copy Markdown
Collaborator

Requirements

  • Fill out the relevant sections below; explain items that do not apply.
  • Add or update appropriate tests for behavior changes. For documentation-only
    changes, explain why test-suite changes are unnecessary and describe the
    documentation or metadata checks performed.
  • Preserve the existing regression, Bash/zsh compatibility and mandatory 100%
    measurable-line coverage gates. Do not weaken checks to obtain a passing result.
  • All status checks must pass before merge. Pending or unrun checks are
    not passing results.

Type

  • Bug fix
  • Feature change
  • Performance
  • Refactor
  • Documentation
  • CI/CD
  • Test
  • Build
  • Style
  • Chore

Issue (only for type bug fix/feature change)

No separate issue filed. The bug was reproduced in a real macOS login zsh where
both $0 and ZSH_ARGZERO are -zsh.

Description of the Change

Fix THIS_SCRIPT_NAME initialization for login shells.

Previously, basename "$_bash_base_argzero" treated -zsh as an option on
macOS and printed basename: illegal option -- z.

The implementation now uses shell parameter expansion and strips the login-shell
leading -. Regression tests cover both -bash and -zsh.

Contract and Compatibility

Regular Bash/zsh invocation names keep the same result.

Login-shell names are normalized:

  • -bash -> bash
  • -zsh -> zsh

THIS_SCRIPT_PATH behavior is intentionally unchanged.

No new dependencies or breaking API changes are introduced.

Validation

Completed:

  • reproduced the bug with a real login zsh: $0=-zsh, ZSH_ARGZERO=-zsh
  • verified the failing code path in the installed Bash-base
  • added login-style Bash/zsh regression coverage
  • verified the Bash -bash normalization path

Pending before merge:

  • npm test
  • mandatory 100% measurable-line coverage gate
  • all GitHub Actions status checks

Possible Drawbacks

The fix removes the external basename call for this value and normalizes a
leading login-shell -.

THIS_SCRIPT_PATH is deliberately not changed; its login-shell semantics may
need separate review.

@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (013a3f7) to head (ba854fc).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #61   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          585       586    +1     
=========================================
+ Hits           585       586    +1     
Flag Coverage Δ
strict-union 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhang-hongjie
zhang-hongjie merged commit 1991453 into master Oct 18, 2026
9 checks passed
@zhang-hongjie
zhang-hongjie deleted the fix/argument-login-shell-invocation branch October 18, 2026 22:05
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant