An educational project based on the curriculum of ucode.world. Uses Meta-circular interpreter under the hood. It is written in C for MacOs.
- execution of external commands (bin files),
- execution of builtins,
- meta-circular interpreter,
- interpretation of complex grammar of input line including command separator ( ; ), logic operators ( && || ), pipeline ( | ), command substitution, redirections,
- expansions of tilda (~),
- variables (
$name, $ {name}), - escape working accordingly in no quote, quote, double quote expressions,
- Ctrl+C, Ctrl+D, Ctrl+Z,
- command history,
- backspace key while inputting line.
Bin files are executed in a separate process.
e.g.
ls
ls -la
/bin/ls -l
- Echo
e.g.
echo "CBL World"
echo CBL World
echo 'CBL World'
echo -n "\a"
- Exit
- cd
- pwd
- env
- set
- unset
- export
- fg
- path
- yes
- true
- false
- jobs
- which
Parsing and execution of the input line is done by implementation of meta-circular interpreter described in the book Structure and Interpretation of Computer Programs.
Details of grammar are here
;
-
||
&&
|
=
- Expansions (see below)
5.1."..."
'...'
5.2.$...
$(...)
5.3.`...`
${...}
5.4.~
- Redirections
6.1.>
6.2.>>
6.3.<
The following types of expansions are performed in the indicated order in five steps:
- Alias Expansion (not implemented)
- Parameter Expansion (only
$name and $ {name}) - Command Substitution
- These are performed in left-to-right fashion. On each argument, any of the five steps that are needed are performed one after the other.
Hence, for example, all the parts of parameter expansion are completed before command substitution is started.
After these expansions, all unquoted occurrences of the characters
\
’
and"
are removed. - Filename Expansion