| Index: go/src/infra/tools/drover/util.go
|
| diff --git a/go/src/infra/tools/drover/util.go b/go/src/infra/tools/drover/util.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ca57b99ba96aa5d98bbb0deeb4ba102b6249ab9b
|
| --- /dev/null
|
| +++ b/go/src/infra/tools/drover/util.go
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +package main
|
| +
|
| +import (
|
| + "fmt"
|
| + "os"
|
| + "os/exec"
|
| + "strings"
|
| +)
|
| +
|
| +func failIf(err error) {
|
| + if err != nil {
|
| + fmt.Println("fatal:", err)
|
| + os.Exit(1)
|
| + }
|
| +}
|
| +
|
| +func SplitLines(data string) []string {
|
| + return strings.Split(strings.TrimRight(data, "\n"), "\n")
|
| +}
|
| +
|
| +func Shell(dir string) bool {
|
| + shell := os.Getenv("SHELL")
|
| + if shell == "" {
|
| + shell = DefaultShell
|
| + }
|
| + shell, err := exec.LookPath(shell)
|
| + failIf(err)
|
| + p, err := os.StartProcess(shell, []string{shell}, &os.ProcAttr{
|
| + Dir: dir,
|
| + Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
|
| + })
|
| + failIf(err)
|
| + s, err := p.Wait()
|
| + failIf(err)
|
| +
|
| + return s.Success()
|
| +}
|
|
|