Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/sops/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func main() {
Name: "background",
Usage: "background the process and don't wait for it to complete",
},
cli.BoolFlag{
Name: "pristine",
Usage: "insert only the decrypted values into the environment without forwarding existing environment variables",
},
cli.StringFlag{
Name: "user",
Usage: "the user to run the command as",
Expand Down Expand Up @@ -171,6 +175,7 @@ func main() {
Command: command,
Plaintext: output,
Background: c.Bool("background"),
Pristine: c.Bool("pristine"),
User: c.String("user"),
}); err != nil {
return toExitError(err)
Expand Down
8 changes: 7 additions & 1 deletion cmd/sops/subcommand/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ExecOpts struct {
Command string
Plaintext []byte
Background bool
Pristine bool
Fifo bool
User string
Filename string
Expand Down Expand Up @@ -83,7 +84,12 @@ func ExecWithEnv(opts ExecOpts) error {
SwitchUser(opts.User)
}

env := os.Environ()
var env []string

if !opts.Pristine {
env = os.Environ()
}

lines := bytes.Split(opts.Plaintext, []byte("\n"))
for _, line := range lines {
if len(line) == 0 {
Expand Down