@@ -51,14 +51,14 @@ func runWithOutput(path string, opts eopts) (output []byte, exitCode int, err er
51
51
return nil , 0 , fmt .Errorf ("get args: %w" , err )
52
52
}
53
53
54
+ args = append (args , path )
55
+
54
56
if len (opts .args ) > 0 {
55
57
for _ , arg := range opts .args {
56
58
args = append (args , arg [0 ], arg [1 ])
57
59
}
58
60
}
59
61
60
- args = append (args , path )
61
-
62
62
cmd := exec .Command ("sudo" , args ... )
63
63
log .Printf ("cmd=%s" , cmd .String ())
64
64
@@ -81,15 +81,24 @@ func runWithWait(ctx context.Context, path string, opts eopts) error {
81
81
82
82
args = append (args , path )
83
83
84
+ if len (opts .args ) > 0 {
85
+ for _ , arg := range opts .args {
86
+ args = append (args , arg [0 ], arg [1 ])
87
+ }
88
+ }
89
+
84
90
cmd := exec .CommandContext (ctx , "sudo" , args ... )
85
91
log .Printf ("cmd=%s" , cmd .String ())
86
92
87
93
if err := cmd .Start (); err != nil {
88
- return fmt .Errorf ("cmd %q: %w" , path , err )
94
+ return fmt .Errorf ("cmd start %q: %w" , path , err )
89
95
}
90
96
91
97
if err := cmd .Wait (); err != nil {
92
- return fmt .Errorf ("cmd %q: %w" , path , err )
98
+ if errors .Is (ctx .Err (), context .Canceled ) {
99
+ return nil
100
+ }
101
+ return fmt .Errorf ("cmd wait %q: %w" , path , err )
93
102
}
94
103
95
104
return nil
0 commit comments