Source File
pwd.go
Belonging Package
src.elv.sh/pkg/eval
package evalimport ()// NewPwdVar returns a variable who value is synchronized with the path of the// current working directory.func ( *Evaler) vars.Var { return pwdVar{} }// pwdVar is a variable whose value always reflects the current working// directory. Setting it changes the current working directory.type pwdVar struct {ev *Evaler}var _ vars.Var = pwdVar{}// Getwd allows for unit test error injection.var Getwd func() (string, error) = os.Getwd// Get returns the current working directory. It returns "/unknown/pwd" when// it cannot be determined.func (pwdVar) () interface{} {, := Getwd()if != nil {// This should really use the path separator appropriate for the// platform but in practice this hardcoded string works fine. Both// because MS Windows supports forward slashes and this will very// rarely occur.return "/unknown/pwd"}return}// Set changes the current working directory.func ( pwdVar) ( interface{}) error {, := .(string)if ! {return vars.ErrPathMustBeString}return .ev.Chdir()}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)