fix: change command parser to not trim whitespaces #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is to allow for commands where passing an empty string as argument
has significance. This should however only be relevant in exceptional
cases. For example, shellharden handles reading from stdin by receiving
an empty string as its "file" argument (in shell done via ''/""):
A translation to Rust std::process style of spawning processes would be:
cmd: "shellharden"
args: ["--transform", ""]
By using
.split_whitespace()
to separate the components of a command,any trailing as well as contiguous sequences of whitespaces are removed,
making it impossible to express the same command via the TOML config:
This PR changes the command parser to treat whitespace individually, and
not trim any away. I guess one drawback of this is that the commands
expressed in the TOML config drift further away from what one perhaps
would expect. By this I mean a shell-like syntax where whitespace don't
matter as much (until they do, by which time you're in for a world of
pain).
I wouldn't mind if this was declined due to similar reasoning, figured
I'd open it anyway and at least highlight the problem. In that case I'll
try to get
-
supported as a filename representing stdin inshellharden
, this PR would be a good motivation for it :)