GoLSh/cmd/cd.go
2025-06-24 16:02:09 -05:00

23 lines
349 B
Go

package cmd
import (
"os"
"gosh/types"
"github.com/fatih/color"
)
func GoshCd(sh *types.Shell, dir string) types.CmdOutput {
err := os.Chdir(dir)
red := color.New(color.FgRed).SprintFunc()
if err != nil {
return types.CmdOutput{Id: 1, Output: red(err)}
}
dir, _ = os.Getwd()
sh.Cd = dir
return types.CmdOutput{Id: 0, Output: ""}
}