A POSIX-compliant shell implementation written in Go from scratch.
- Command execution with argument parsing
- Pipeline support (
cmd1 | cmd2 | cmd3
) - I/O redirection (
>
,>>
,2>
,2>>
) - Built-in commands: cd, pwd, echo, exit, type, history
- Command history with file persistence
- Tab completion with prefix matching
- Rich line editing (powered by readline)
- Quote handling (single/double)
- Home directory expansion (
~
)
# Install Go 1.24 or higher
go mod download
# Run the shell using the provided script
./your_program.sh
# Interactive shell will start (type 'exit' to quit)
$ echo "Hello World!"
$ ls -la
$ pwd
-
Command Processing
- Lexical analysis and token parsing
- Advanced quote and escape handling
- Multi-stage pipeline execution with buffering
- Process spawning and lifecycle management
-
Shell Features
- File descriptor management for I/O redirection
- History with readline integration
- Tab completion using prefix matching
-
Go Specifics
- Goroutines for concurrent command execution
- Sync primitives (WaitGroup, Mutex)
- Standard library syscall integration
app/
├── main.go # Core shell implementation
├── read_env.go # Environment and PATH handling
├── history.go # History management
└── autocomplete.go # Completion engine
Built as part of the "Build Your Own Shell" challenge on CodeCrafters.