Skip to content

Conversation

ipince
Copy link
Contributor

@ipince ipince commented Jan 27, 2023

Summary

Before this fix, if your had export FOO=bar in your init hook, and you had a script "foo": "echo $FOO", then these two commands would have different results:

> devbox run foo
bar

> devbox run -- echo '$FOO'

The second invocation should also return bar. This change makes it so.

Note that the implementation is a bit odd. I left a comment explaining why it's so.

How was it tested?

Ran the commands in the description above and they both returned the same.

@ipince ipince requested a review from savil January 27, 2023 23:30
}
cmdWithArgs = []string{d.scriptPath(d.scriptFilename(arbitraryCmdFilename))}
// TODO: move this env var elsewhere. I will move all the env stuff into a single ComputeEnv() function.
pluginEnv = append(pluginEnv, fmt.Sprintf("DEVBOX_RUN_CMD=%s", strings.Join(append([]string{cmdName}, cmdArgs...), " ")))
Copy link
Collaborator

Choose a reason for hiding this comment

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

is pluginEnv the environment generated after the init-hooks and plugin-hooks have run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, the stuff in pluginEnv comes first. do you have a concern related to ordering?

@ipince ipince force-pushed the rodrigo/run-cmd-hooks branch from ebc18d2 to c896751 Compare February 7, 2023 06:17
@ipince ipince merged commit 9e37940 into main Feb 7, 2023
@ipince ipince deleted the rodrigo/run-cmd-hooks branch February 7, 2023 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants