Skip to content

Commit

Permalink
cmd/testscript: minor bug fixes (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
myitcv authored Jan 9, 2019
1 parent dc3eec0 commit abaa39a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/testscript/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ func main() {
}

func main1() int {
if err := mainerr(); err != nil {
switch err := mainerr(); err {
case nil:
return 0
case flag.ErrHelp:
return 2
default:
fmt.Fprintln(os.Stderr, err)
return 1
}
return 0
}

func mainerr() (retErr error) {
Expand All @@ -55,8 +59,9 @@ func mainerr() (retErr error) {
if err != nil {
return fmt.Errorf("unable to create temp dir: %v", err)
}
fmt.Printf("temporary work directory: %v\n", td)
if !*fWork {
if *fWork {
fmt.Fprintf(os.Stderr, "temporary work directory: %v\n", td)
} else {
defer os.RemoveAll(td)
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/testscript/testdata/work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# should support skip
unquote file.txt

testscript -v -work file.txt
stderr '\Qtemporary work directory: '$WORK'\E[/\\]tmp[/\\]'

-- file.txt --
>exec true

0 comments on commit abaa39a

Please sign in to comment.