Skip to content
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 (

@@ -55,26 +52,3 @@ func ExampleFields() {
// []string{"unquoted", "bar", "baz"}
// []string{"quoted", "bar baz"}

func ExampleSourceFile() {
src := `
if true; then
bar=$(echo example_*.go)
ioutil.WriteFile("", []byte(src), 0666)
defer os.Remove("")
vars, err := shell.SourceFile(context.TODO(), "")
if err != nil {
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.