Skip to content

Commit 9f7ab79

Browse files
committed
Improve error handling and parameter validation
Signed-off-by: Ricardo Matsui <ricmatsui@gmail.com>
1 parent d922d36 commit 9f7ab79

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cmd/sops/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ func main() {
198198

199199
if c.Bool("background") {
200200
log.Warn("exec-env's --background option is deprecated and will be removed in a future version of sops")
201+
202+
if c.Bool("same-process") {
203+
return common.NewExitError("Error: The --same-process flag cannot be used with --background", codes.ErrorConflictingParameters)
204+
}
201205
}
202206

203207
tree, err := decryptTree(opts)

cmd/sops/subcommand/exec/exec.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package exec
22

33
import (
44
"bytes"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"runtime"
@@ -116,6 +117,10 @@ func ExecWithEnv(opts ExecOpts) error {
116117
SwitchUser(opts.User)
117118
}
118119

120+
if runtime.GOOS == "windows" && opts.SameProcess {
121+
return fmt.Errorf("The --same-process flag is not supported on Windows")
122+
}
123+
119124
var env []string
120125

121126
if !opts.Pristine {

0 commit comments

Comments
 (0)