bats/helpers: Improve create_forwarding_script #195
Merged
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.
Also adds
create_forwarding_scripts
to create multiple forwarding scripts in one call.The updates to
create_forwrading_script
addresses several shortcomings that became apparent while using it to test the new test helperskip_if_missing_background_utilities
that I'm adding as part of #181.First, I needed a way to better restrict the
PATH
of the forwarded command. Trying to setPATH
while invokingcreate_forwarding_script
would lead to no forwarding script being created ifPATH
excluded the directory containing the forwarded program. The new--path
option resolves this.That specific change also resolved a bug where
$@
was passed tostub_program_in_path
, rather than just the command name argument, causing the script to contain the arguments after the command name.It then became apparent that the forwarding script needed to
exec
the wrapped command. As explained in the implementation comments: