@@ -52,6 +52,7 @@ var ShallowCloneDepth int
52
52
var logFile * os.File
53
53
var SkipNewtCompat bool
54
54
var SkipSyscfgRepoHash bool
55
+ var HideLoadCmdOutput bool
55
56
56
57
func ParseEqualsPair (v string ) (string , string , error ) {
57
58
s := strings .Split (v , "=" )
@@ -352,38 +353,14 @@ func EnvironAsMap() (map[string]string, error) {
352
353
return m , nil
353
354
}
354
355
355
- // Execute the specified process and block until it completes. Additionally,
356
- // the amount of combined stdout+stderr output to be logged to the debug log
357
- // can be restricted to a maximum number of characters.
358
- //
359
- // @param cmdStrs The "argv" strings of the command to execute.
360
- // @param env Additional key,value pairs to inject into the
361
- // child process's environment. Specify null
362
- // to just inherit the parent environment.
363
- // @param logCmd Whether to log the command being executed.
364
- // @param maxDbgOutputChrs The maximum number of combined stdout+stderr
365
- // characters to write to the debug log.
366
- // Specify -1 for no limit; 0 for no output.
367
- //
368
- // @return []byte Combined stdout and stderr output of process.
369
- // @return error NewtError on failure. Use IsExit() to
370
- // determine if the command failed to execute
371
- // or if it just returned a non-zero exit
372
- // status.
373
- func ShellCommandLimitDbgOutput (
374
- cmdStrs []string , env map [string ]string , logCmd bool ,
375
- maxDbgOutputChrs int ) ([]byte , error ) {
356
+ func ShellCommandInit (cmdStrs []string , env map [string ]string ) (* exec.Cmd , error ) {
376
357
377
358
var name string
378
359
var args []string
379
360
380
361
// Escape special characters for Windows.
381
362
fixupCmdArgs (cmdStrs )
382
363
383
- if logCmd {
384
- LogShellCmd (cmdStrs , env )
385
- }
386
-
387
364
if ExecuteShell && (runtime .GOOS == "linux" || runtime .GOOS == "darwin" ) {
388
365
cmd := strings .Join (cmdStrs , " " )
389
366
name = "/bin/sh"
@@ -418,6 +395,75 @@ func ShellCommandLimitDbgOutput(
418
395
cmd .Env = EnvVarsToSlice (m )
419
396
}
420
397
398
+ return cmd , nil
399
+ }
400
+
401
+ // Execute the specified process and block until it completes. Process'
402
+ // output will be redirected to the stdout and stderr if output log is enabled
403
+ //
404
+ // @param cmdStrs The "argv" strings of the command to execute.
405
+ // @param env Additional key,value pairs to inject into the
406
+ // child process's environment. Specify null
407
+ // to just inherit the parent environment.
408
+ // @param logCmd Whether to log the command being executed.
409
+ // @param maxDbgOutputChrs Whether to log the output of the process
410
+ //
411
+ // @return error NewtError on failure. Use IsExit() to
412
+ // determine if the command failed to execute
413
+ // or if it just returned a non-zero exit
414
+ // status.
415
+ func ShellCommandStreamOutput (
416
+ cmdStrs []string , env map [string ]string , logCmd bool ,
417
+ logOutput bool ) error {
418
+
419
+ cmd , err := ShellCommandInit (cmdStrs , env )
420
+ if err != nil {
421
+ return err
422
+ }
423
+
424
+ if logCmd {
425
+ LogShellCmd (cmdStrs , env )
426
+ }
427
+
428
+ if logOutput {
429
+ cmd .Stdout = os .Stdout
430
+ cmd .Stderr = os .Stderr
431
+ }
432
+
433
+ return cmd .Run ()
434
+ }
435
+
436
+ // Execute the specified process and block until it completes. Additionally,
437
+ // the amount of combined stdout+stderr output to be logged to the debug log
438
+ // can be restricted to a maximum number of characters.
439
+ //
440
+ // @param cmdStrs The "argv" strings of the command to execute.
441
+ // @param env Additional key,value pairs to inject into the
442
+ // child process's environment. Specify null
443
+ // to just inherit the parent environment.
444
+ // @param logCmd Whether to log the command being executed.
445
+ // @param maxDbgOutputChrs The maximum number of combined stdout+stderr
446
+ // characters to write to the debug log.
447
+ // Specify -1 for no limit; 0 for no output.
448
+ //
449
+ // @return []byte Combined stdout and stderr output of process.
450
+ // @return error NewtError on failure. Use IsExit() to
451
+ // determine if the command failed to execute
452
+ // or if it just returned a non-zero exit
453
+ // status.
454
+ func ShellCommandLimitDbgOutput (
455
+ cmdStrs []string , env map [string ]string , logCmd bool ,
456
+ maxDbgOutputChrs int ) ([]byte , error ) {
457
+
458
+ cmd , err := ShellCommandInit (cmdStrs , env )
459
+ if err != nil {
460
+ return nil , err
461
+ }
462
+
463
+ if logCmd {
464
+ LogShellCmd (cmdStrs , env )
465
+ }
466
+
421
467
o , err := cmd .CombinedOutput ()
422
468
423
469
if maxDbgOutputChrs < 0 || len (o ) <= maxDbgOutputChrs {
0 commit comments