rycus86 / githooks

Githooks: per-repo and global Git hooks with version control
MIT License
380 stars 19 forks source link

Make script more deterministic by clearing `CDPATH` #164

Closed hyperupcall closed 2 months ago

hyperupcall commented 10 months ago

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.

rycus86 commented 10 months ago

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?

coveralls commented 10 months ago

Pull Request Test Coverage Report for Build 6588736445


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