githooks
githooks copied to clipboard
Make script more deterministic by clearing `CDPATH`
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.
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?
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 | |
|---|---|
| Change from base Build 4543718405: | 0.1% |
| Covered Lines: | 2515 |
| Relevant Lines: | 3136 |