bashfs

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CleanPath = cmds.CleanPath

CleanPath normalises a path to always start with / and removes . and .. segments.

View Source
var WalkDir = cmds.WalkDir

WalkDir walks the filesystem tree rooted at root, calling fn for each file or directory.

Functions

func ErrIsDirectory

func ErrIsDirectory(p string) error

ErrIsDirectory is returned when a file operation is attempted on a directory.

func ErrNotDirectory

func ErrNotDirectory(p string) error

ErrNotDirectory is returned when a directory operation is attempted on a file.

func ErrNotFound

func ErrNotFound(p string) error

ErrNotFound is returned when a path does not exist.

func SplitArgs

func SplitArgs(line string) []string

SplitArgs splits a command line into args, respecting single and double quotes.

Types

type CmdContext

type CmdContext = cmds.CmdContext

CmdContext is the interface commands use to interact with the shell.

type FileInfo

type FileInfo = cmds.FileInfo

FileInfo represents a file or directory in the virtual filesystem.

func Dir

func Dir(p string, modTime time.Time) *FileInfo

Dir is a convenience constructor for a directory FileInfo.

func File

func File(name, filePath string, content []byte, modTime time.Time) *FileInfo

File is a convenience constructor for a file FileInfo.

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) AllEnv

func (s *Shell) AllEnv() map[string]string

func (*Shell) Cwd

func (s *Shell) Cwd() string

func (*Shell) DeleteEnv

func (s *Shell) DeleteEnv(key string)

func (*Shell) Exec

func (s *Shell) Exec(cmdLine string, w io.Writer, errW io.Writer, stdin io.Reader) int

Exec parses and executes a single command line.

func (*Shell) ExecPipeline

func (s *Shell) ExecPipeline(line string, w io.Writer, errW io.Writer, stdin io.Reader) int

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) GetEnv

func (s *Shell) GetEnv(key string) string

func (*Shell) Resolve

func (s *Shell) Resolve(p string) string

func (*Shell) RunInteractive

func (s *Shell) RunInteractive(rw io.ReadWriter, errW io.Writer, motd string, prompt string)

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.

func (*Shell) SetCwd

func (s *Shell) SetCwd(dir string)

func (*Shell) SetEnv

func (s *Shell) SetEnv(key, value string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL