My blog post: Building a Shell
A tiny shell in C with pipes, cd, env var expansion, history, and tab completion.
./andsh
andsh$ cd /
andsh$ pwd
/
andsh$ echo $HOME
/Users/andrew
andsh$ nosuchcommand
nosuchcommand: No such file or directory
andsh$ echo $?
127
andsh$ printf abc\n | tr a-z A-Z | rev
CBA
andsh$ ec<Tab> hello
andsh$ echo hello
hello
andsh$ <Up>
andsh$ echo hello
hello
andsh$ ^D
I'm building it up a piece at a time, mostly to learn more about how shells work under the hood and to have something to write about.
build
make
run
./andshNon-goal: try to be bash or zsh.
Note: I've only tested on macOS.
./test.sh
ok - build
ok - echo
ok - cd
ok - cd home
ok - env var
nosuchcommand: No such file or directory
ok - last status
ok - pipe
ok - completion
ok - ctrl-d exits
ok - history
ok - left right
11 passed, 0 failed