seehell
A Linux shell in C and x86 assembly
A basic Linux shell in C that talks to the kernel through hand-written x86 assembly syscalls.

- Fields
- Interests
- Language
- Year
- 2022 · last push 2022-05-04
- GitHub
- 0 (2026-11-07)
README
Straight from the project’s GitHub repository. (2026-11-07) · GitHub
Ondrej Spanik (c) iairu.com 2022
Program parts
syscall.S, syscall.h
- Custom
syscallcalling using Assembly0x80interrupt method insyscall.Sand interface with C usingsyscall.halongside helpful comments regarding origin of other system calls.
main.c
Contents of the main function explain the flow pretty well:
- Process any external arguments using
processArgs - Prepare the socket if requested in arguments
- Inform the user about how the shell is ran (on socket as client or server / without socket)
- Prepare buffer for user input
- Interactive shell loop consisting of:
- Print up-to-date prompt
- Retrieve user input until new line
- If the user input contains a built-in command, execute it internally (note: no support for arguments for now as it wasn't deemed necessary)
- Else proceed to argument parsing for external commands / programs
- Handle program execution (forking, waiting, ...)
- Free processed arguments from dynamic memory
- Free buffers from dynamic memory
Additional documentation
processArgs
External arguments handling. Defines internal behavior.
parseArgs
Internal user input argument parsing into array.
Special characters
| Character | Expected behavior | Implementation notes |
|---|---|---|
# |
comment | rest of the input is ignored |
; |
next input | |
< |
||
> |
||
| ` | ` | pipe |
\ |
escape | literal treatment of ", space, #, others NYI |
Additional processing behavior:
- Double quotes
"are treated as special characters unless escaped with\. They allow for (multiple) spaces to be inserted without the need for individual escapes. - Spaces are allowed to be escaped for literal treatment.
- Check for matching pair of double quotes.
- Processing of
n>(stream redirection) is not considered because it is viewed as a separate operator from>
Improvement suggestions
- Major improvements are flagged with
// todowithin code - Minor improvements are flagged with
// _todowithin code


