feat: allow bypassing chalk via CHALK_BYPASS environment variable
Description
@nettrino and I had a good discussion earlier today about bypassing chalk (issue https://github.com/crashappsec/chalk/issues/224). Here's a sketch of a possible implementation.
This is the "avoid as much chalk as possible" flavor, optimizing for a completely independent, minimal code path.
It allows bypassing the exec command:
$ CHALK_BYPASS=1 chalk exec echo hi
chalk: the CHALK_BYPASS environment variable is set.
Running the following command without chalk:
echo hi
hi
and bypassing the docker command:
$ CHALK_BYPASS=1 chalk docker --version
chalk: the CHALK_BYPASS environment variable is set.
Running the following command without chalk:
docker --version
Docker version 25.0.3, build 4debf411d1
and errors when the command is not docker or exec:
$ CHALK_BYPASS=1 chalk version
error: CHALK_BYPASS was set, but the chalk command is not 'docker' or 'exec'. Quitting.
Refs: #224
Testing
Run commands like illustrated above.
To-do
If we wanted to continue in this direction:
- [ ] Tests
- [ ] Docs
- [ ] Consider handling
chalkbeing nameddocker
Per my last comment on the linked issue, I really don't think we should do this before the con4m refactor without a very good reason.
+1. this approach I think breaks a bunch of semantics about chalk comment. if we need to bypass chalk, I think we need to do that in such a way which bypasses error-prone areas of chalk such as anything to do with user configs/reporting/etc without breaking user semantics
for example chalk exec needs to grab some potential exec args from either command line args or embedded config. saying that CHALK_BYPASS now breaks some chalk commands depending on context I dont think is acceptable.
a lot of con4m evaluation will be nop in v2 so over there we can correctly skip just the bits in chalk which can possible blow up such as chalk collection/reporting/etc.
closing as we wont be taking this approach in the long term and this just pollutes PRs list