githooks icon indicating copy to clipboard operation
githooks copied to clipboard

Make script more deterministic by clearing `CDPATH`

Open hyperupcall opened this issue 2 years ago • 2 comments

As mentioned in POSIX, the environment variable CDPATH chagnes the behavior of cd. Notably, it can cause the directory to be changed to an unexpected location. This makes the script less deterministic.

My changeset causes CDPATH to be taken account by either unsetting it, or setting it to an empty string.

hyperupcall avatar Oct 20 '23 14:10 hyperupcall

Hi @hyperupcall can you explain a scenario when this might cause problems? Do you perhaps have an idea for a test we could add in this repo? The change itself sounds sensible for a bit of extra complexity, but also wondering why this wasn't necessary until now?

rycus86 avatar Oct 22 '23 23:10 rycus86

Pull Request Test Coverage Report for Build 6588736445

  • 4 of 4 (100.0%) changed or added relevant lines in 4 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 80.198%

Files with Coverage Reduction New Missed Lines %
cli.sh 2 83.79%
<!-- Total: 2
Totals Coverage Status
Change from base Build 4543718405: 0.1%
Covered Lines: 2515
Relevant Lines: 3136

💛 - Coveralls

coveralls avatar Oct 22 '23 23:10 coveralls