Documentation
¶
Index ¶
- Variables
- func ErrIsDirectory(p string) error
- func ErrNotDirectory(p string) error
- func ErrNotFound(p string) error
- func SplitArgs(line string) []string
- type CmdContext
- type FileInfo
- type FileSystem
- type Shell
- func (s *Shell) AllEnv() map[string]string
- func (s *Shell) Cwd() string
- func (s *Shell) DeleteEnv(key string)
- func (s *Shell) Exec(cmdLine string, w io.Writer, errW io.Writer, stdin io.Reader) int
- func (s *Shell) ExecPipeline(line string, w io.Writer, errW io.Writer, stdin io.Reader) int
- func (s *Shell) FS() FileSystem
- func (s *Shell) GetEnv(key string) string
- func (s *Shell) Resolve(p string) string
- func (s *Shell) RunInteractive(rw io.ReadWriter, errW io.Writer, motd string, prompt string)
- func (s *Shell) SetCwd(dir string)
- func (s *Shell) SetEnv(key, value string)
Constants ¶
This section is empty.
Variables ¶
var CleanPath = cmds.CleanPath
CleanPath normalises a path to always start with / and removes . and .. segments.
var WalkDir = cmds.WalkDir
WalkDir walks the filesystem tree rooted at root, calling fn for each file or directory.
Functions ¶
func ErrIsDirectory ¶
ErrIsDirectory is returned when a file operation is attempted on a directory.
func ErrNotDirectory ¶
ErrNotDirectory is returned when a directory operation is attempted on a file.
func ErrNotFound ¶
ErrNotFound is returned when a path does not exist.
Types ¶
type CmdContext ¶
type CmdContext = cmds.CmdContext
CmdContext is the interface commands use to interact with the shell.
type FileInfo ¶
FileInfo represents a file or directory in the virtual filesystem.
type FileSystem ¶
type FileSystem = cmds.FileSystem
FileSystem is the interface that bashfs operates on.
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell is a restricted bash-like shell that operates over any FileSystem.
func NewShell ¶
func NewShell(fs FileSystem) *Shell
NewShell creates a new Shell backed by the given FileSystem.
func (*Shell) ExecPipeline ¶
ExecPipeline parses a shell line and executes the resulting AST. stdin is optional — pass nil if no external stdin is available.
func (*Shell) FS ¶
func (s *Shell) FS() FileSystem
func (*Shell) RunInteractive ¶
RunInteractive runs an interactive shell session. rw is used for both reading input and writing output. When running over an SSH session with an allocated PTY, the session's ptyWriter already converts \n to \r\n, so no additional CRLFWriter wrapping is needed.