...
1 package sh_test
2
3 import (
4 "fmt"
5
6 "github.com/codeskyblue/go-sh"
7 )
8
9 func ExampleCommand() {
10 out, err := sh.Command("echo", "hello").Output()
11 fmt.Println(string(out), err)
12 }
13
14 func ExampleCommandPipe() {
15 out, err := sh.Command("echo", "-n", "hi").Command("wc", "-c").Output()
16 fmt.Println(string(out), err)
17 }
18
19 func ExampleCommandSetDir() {
20 out, err := sh.Command("pwd", sh.Dir("/")).Output()
21 fmt.Println(string(out), err)
22 }
23
24 func ExampleTest() {
25 if sh.Test("dir", "mydir") {
26 fmt.Println("mydir exists")
27 }
28 }
29
View as plain text