Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden code against mocks/stubs #8

Open
Flamefire opened this issue Jun 14, 2019 · 0 comments · May be fixed by #9
Open

Harden code against mocks/stubs #8

Flamefire opened this issue Jun 14, 2019 · 0 comments · May be fixed by #9

Comments

@Flamefire
Copy link

Flamefire commented Jun 14, 2019

The code uses e.g cat which may be mocked/stubbed by the user and point to something else.

I'd suggest to get the real locations on startup (e.g. command -v cat or which cat) and save them for later use.

Alternative:

During startup (global scope): _BATSLIB_PATH="$PATH"
Call site: PATH="$_BATSLIB_PATH" \cat -

This resets the path and avoids macro/alias expansion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant