Last active
March 29, 2022 07:02
-
-
Save raylu/5c6d570ae186f963ad2d to your computer and use it in GitHub Desktop.
shell starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
while True: | |
line = input('> ') | |
os.execvp(line, [line]) | |
# 0. run this code and try `ls` to make sure that much works | |
# 1. handle arguments (`ls /`) | |
# 2. don't exit after a command runs (use os.fork and .wait) | |
# 3. I/O redirection (`echo hi > out`; use os.dup2) | |
# 4. builtins (`cd`, `pwd` for now) | |
# 5. forward signals (just SIGINT for now, use signal) | |
# 6. pipes (`ls | sort`; use os.pipe) | |
# 7. job control part 1: handle commands ending in `&` | |
# 8. job control part 2: Ctrl+Z == SIGSTOP, `jobs`, `fg`, `bg` | |
# see also: | |
# http://doc.cat-v.org/unix/pipes/ | |
# https://www.raylu.net/systems/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment