github.com/verrazzano/verrazzano@v1.7.0/pkg/os/shell.go (about)

     1  // Copyright (c) 2021, 2022, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package os
     5  
     6  import (
     7  	osexec "os/exec"
     8  )
     9  
    10  // bashRunner needed for unit tests
    11  var bashRunner CmdRunner = DefaultRunner{}
    12  
    13  // RunBash runs a bash script
    14  func RunBash(inArgs ...string) (string, string, error) {
    15  	args := []string{}
    16  	for i := range inArgs {
    17  		args = append(args, inArgs[i])
    18  	}
    19  	cmd := osexec.Command("bash", args...)
    20  	stdout, stderr, err := bashRunner.Run(cmd)
    21  	if err != nil {
    22  		return string(stdout), string(stderr), err
    23  	}
    24  	return string(stdout), "", err
    25  }