Skip to content
Permalink
Browse files

shell: remove Source* funcs

They were a bit basic and not very configurable. For example, they
didn't allow for any parser or interpreter options, and stdout/stderr
were entirely ignored.

We could redo the APIs to make them more powerful, but there's probably
little point. If someone wants that much customization, they could write
the dozen lines of code themselves and have all the power.

The only internal detail from the removed code are the predefined
variables like $HOME and $PWD. We might re-expose this somehow in the
interp package, as it could be useful in general.

Fixes #427.
  • Loading branch information
mvdan committed Dec 16, 2019
1 parent 015d6d6 commit fff3b334246a1f326d25b3ad2d0cdc4e4686c1f4
Showing with 0 additions and 209 deletions.
  1. +0 −26 shell/example_test.go
  2. +0 −57 shell/source.go
  3. +0 −126 shell/source_test.go
@@ -4,10 +4,7 @@
package shell_test

import (
"context"
"fmt"
"io/ioutil"
"os"

"mvdan.cc/sh/v3/shell"
)
@@ -55,26 +52,3 @@ func ExampleFields() {
// []string{"unquoted", "bar", "baz"}
// []string{"quoted", "bar baz"}
}

func ExampleSourceFile() {
src := `
foo=abc
foo+=012
if true; then
bar=$(echo example_*.go)
fi
`
ioutil.WriteFile("f.sh", []byte(src), 0666)
defer os.Remove("f.sh")
vars, err := shell.SourceFile(context.TODO(), "f.sh")
if err != nil {
return
}
fmt.Println(len(vars))
fmt.Println("foo", vars["foo"])
fmt.Println("bar", vars["bar"])
// Output:
// 2
// foo abc012
// bar example_test.go
}

This file was deleted.

This file was deleted.

0 comments on commit fff3b33

Please sign in to comment.
You can’t perform that action at this time.