Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the directory in a subshell is not working #1125

Open
Maks1mS opened this issue Jan 23, 2025 · 0 comments
Open

Changing the directory in a subshell is not working #1125

Maks1mS opened this issue Jan 23, 2025 · 0 comments

Comments

@Maks1mS
Copy link

Maks1mS commented Jan 23, 2025

Example:

package main

import (
	"context"
	"os"
	"strings"

	"mvdan.cc/sh/v3/interp"
	"mvdan.cc/sh/v3/syntax"
)

func main() {
	ctx := context.Background()
	r, _ := interp.New(
		interp.Dir("/opt"),
		interp.StdIO(os.Stdin, os.Stdout, os.Stderr),
	)
	file, _ := syntax.NewParser().Parse(strings.NewReader("echo $PWD"), "")
	r.Run(ctx, file)

	sub := r.Subshell()
	interp.Dir("/")(sub)
	sub.Run(ctx, file)
}

Output:

/opt
/opt

Expected:

/opt
/

May be is related with #1007

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant