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

main: Try to expand arguments starting with "@" from files on disk #2457

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

apparentlymart
Copy link
Contributor

This is a GCC-like behavior where we preproces the argument vector by trying to treat any argument starting with "@" as a placeholder for arguments loaded from a given filename.

As with GCC, if the remainder of the string cannot be used as a filename to open and read, the original argument is retained literally. However, if it is possible to open and read a file of the given name then we take that as sufficient evidence of the operator's intent to read from that file and will fail with an error message if the file contents are not acceptable syntax.

This uses the same upstream library as we've already been using for the TF_CLI_ARGS... environment variables. Since main.go was quite overcrowded with various different concerns, the handling of those environment variables also moves into the new arguments.go file here, since the two share an upstream dependency and both involve simplistic substitutions and insertions into the argument vector. The observable behavior of the environment variable handling should not be changed in any way by this commit.


For the moment this is just a draft to play with the idea from #2429. I'm going to add some commentary in that issue about some quirks of the upstream library we're using here that might be concerning, some (but not all) of which are currently reflected in the test failures on this PR.

This is a GCC-like behavior where we preproces the argument vector by
trying to treat any argument starting with "@" as a placeholder for
arguments loaded from a given filename.

As with GCC, if the remainder of the string cannot be used as a filename
to open and read, the original argument is retained literally. However,
if it _is_ possible to open and read a file of the given name then we
take that as sufficient evidence of the operator's intent to read from
that file and will fail with an error message if the file contents are not
acceptable syntax.

This uses the same upstream library as we've already been using for the
TF_CLI_ARGS... environment variables. Since main.go was quite overcrowded
with various different concerns, the handling of those environment
variables also moves into the new arguments.go file here, since the two
share an upstream dependency and both involve simplistic substitutions and
insertions into the argument vector. The observable behavior of the
environment variable handling should not be changed in any way by this
commit.

Signed-off-by: Martin Atkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant