Skip to content

cmd/testscript: allow -e flag to pass env value#122

Merged
myitcv merged 1 commit intomasterfrom
allow_env_var_values
Jan 19, 2021
Merged

cmd/testscript: allow -e flag to pass env value#122
myitcv merged 1 commit intomasterfrom
allow_env_var_values

Conversation

@myitcv
Copy link
Copy Markdown
Collaborator

@myitcv myitcv commented Jan 19, 2021

The -e flag for testscript currently allows the caller to specify that
environment variables are inherited from the current environment.

However this falls when the current environment does not have a value
set and you need to set a specific value. For example:

GOBUILD=$(go env GOBUILD) testscript -e GOBUILD script.txt

Instead, allow -e to also specify a value:

testscript -e GOBUILD=$(go env GOBUILD) script.txt

which feels more fluent/natural.

@myitcv myitcv requested a review from rogpeppe January 19, 2021 06:34
@myitcv myitcv force-pushed the allow_env_var_values branch 2 times, most recently from ce7213b to b38072b Compare January 19, 2021 09:15
Copy link
Copy Markdown
Owner

@rogpeppe rogpeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple of minor suggestions, thanks!

Comment thread cmd/testscript/main.go Outdated
Comment thread cmd/testscript/main.go
Comment thread cmd/testscript/main.go
The -e flag for testscript currently allows the caller to specify that
environment variables are inherited from the current environment.

However this falls when the current environment does not have a value
set and you need to set a specific value. For example:

    GOBUILD=$(go env GOBUILD) testscript -e GOBUILD script.txt

Instead, allow -e to also specify a value:

    testscript -e GOBUILD=$(go env GOBUILD) script.txt

which feels more fluent/natural.
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.

2 participants