ColorEchoForShell icon indicating copy to clipboard operation
ColorEchoForShell copied to clipboard

fix(test-scripts/sh): use $0 instead of $_

Open moormaster opened this issue 2 months ago • 4 comments

User description

I stumbled accross this while working on #2 .

Fixes an error that occurs when running ./test-scripts/sh:

$ test-scripts/sh
dirname: invalid option -- 'e'
Try 'dirname --help' for more information.
test-scripts/sh: line 4: cd: null directory

After execution of line 3 set -e variable $_ gets overwritten with "set -e". Line 4 tries to get the dirname for "set -e" and fails.


PR Type

Bug fix


Description

  • Fix shell script variable reference error

  • Replace $_ with $0 for directory resolution


Diagram Walkthrough

flowchart LR
  A["Script execution"] --> B["set -e command"]
  B --> C["$_ gets overwritten"]
  C --> D["dirname fails with 'invalid option -e'"]
  E["Use $0 instead"] --> F["Correct directory resolution"]

File Walkthrough

Relevant files
Bug fix
sh
Fix directory resolution variable reference                           

test-scripts/sh

  • Replace $_ with $0 in dirname command
  • Fix variable reference that was overwritten by set -e
+1/-1     

Summary by CodeRabbit

  • Refactor
    • Reworked shell script path resolution to be more robust when invoked from different directories or shells, reducing environment-specific quirks.
  • Tests
    • Improved reliability of test scripts by ensuring dependencies are located and loaded correctly regardless of invocation path, helping prevent intermittent failures on CI and local setups. No changes to test coverage or outcomes.

moormaster avatar Oct 01 '25 22:10 moormaster