Skip to content

Commit 076f27f

Browse files
committed
add environment options function
1 parent 12f730b commit 076f27f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Default option functions:
3636
- `cmd.WithTimeout(time.Duration)`
3737
- `cmd.WithoutTimeout`
3838
- `cmd.WithWorkingDir(string)`
39+
- `cmd.WithEnvironment`
3940

4041
#### Example
4142

command.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ func WithWorkingDir(dir string) func(c *Command) {
9595
}
9696
}
9797

98+
// WithEnvironment adds all environments from the current process to the command
99+
func WithEnvironment(c *Command) {
100+
c.Env = os.Environ()
101+
}
102+
98103
// AddEnv adds an environment variable to the command
99104
// If a variable gets passed like ${VAR_NAME} the env variable will be read out by the current shell
100105
func (c *Command) AddEnv(key string, value string) {

0 commit comments

Comments
 (0)