Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unix-shell

A small Unix-like shell written in Go.

This project runs an interactive prompt, executes built-in commands, resolves external programs from PATH, and supports basic shell parsing features such as quoting, escaping, tilde expansion, and output redirection.

What it supports

  • Built-ins: exit, echo, pwd, type, cd
  • External command execution through PATH
  • Single quotes and double quotes
  • Backslash escaping
  • ~ expansion for the home directory
  • Redirection for stdout and stderr:
    • >
    • >>
    • 1>
    • 1>>
    • 2>
    • 2>>

Project layout

app/
  main.go              interactive shell loop
  commands/
    tokens.go          command parsing and redirection detection
    run.go             external command execution
    helpers.go         output helpers for built-ins

Run locally

Requirements:

  • Go installed locally

Start the shell:

./run.sh

If you prefer running Go directly:

go run ./app

Example commands

pwd
echo hello world
type echo
cd /tmp
ls
echo "hello" > out.txt
cat missing.txt 2> errors.txt
echo again >> out.txt

Notes

  • Built-in output redirection is handled inside the shell.
  • External commands inherit the current terminal unless redirected.
  • On Windows/MSYS environments, append redirection is handled explicitly for better compatibility with child processes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages