| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 package main |
| 5 |
| 6 import ( |
| 7 "fmt" |
| 8 "os" |
| 9 "os/exec" |
| 10 "strings" |
| 11 ) |
| 12 |
| 13 func failIf(err error) { |
| 14 if err != nil { |
| 15 fmt.Println("fatal:", err) |
| 16 os.Exit(1) |
| 17 } |
| 18 } |
| 19 |
| 20 func SplitLines(data string) []string { |
| 21 return strings.Split(strings.TrimRight(data, "\n"), "\n") |
| 22 } |
| 23 |
| 24 func Shell(dir string) bool { |
| 25 shell := os.Getenv("SHELL") |
| 26 if shell == "" { |
| 27 shell = DefaultShell |
| 28 } |
| 29 shell, err := exec.LookPath(shell) |
| 30 failIf(err) |
| 31 p, err := os.StartProcess(shell, []string{shell}, &os.ProcAttr{ |
| 32 Dir: dir, |
| 33 Files: []*os.File{os.Stdin, os.Stdout, os.Stderr}, |
| 34 }) |
| 35 failIf(err) |
| 36 s, err := p.Wait() |
| 37 failIf(err) |
| 38 |
| 39 return s.Success() |
| 40 } |
| OLD | NEW |