This is a small shell that follows subset of POSIX shell standard.
- redirection operators (
<, >, <<, >>
) - commandline pipe (
|
) - quoting (
', "
) - parameter expansion (
$WORD
) and environment variables management (export, env, unset
) - bulit-in commands (
cd, pwd, echo, exit
) - conditional operators (
&&, ||
)
- libreadline developer package (>= 8.12) for terminal input
gettext
for configuration
Recommend using package manager like apt
or brew
to install the library.
brew install readline gettext
apt-get install libreadline-dev gettext
Run ./configure.sh && make
to configure and build.
You may need to adjust library path manually if configure script does not work.
Run make debug
to build in debug mode. It will enable
- compiler options (debug symbol, sanitizer)
- parser output printing
- exit value
test_script.sh
receives a file that has commands to be tested. There is one test case per line. Each test case will be executed in this shell and bash. stdout, exit value pair of both will be compared to decide correctness.
Summary will be printed on stdout and details will be stored in test_log.txt
.
echo 'a'*
echo *$NOTHING
echo $NOTHING*
ls | cat -e && gcc -v || echo "$TERM"
#9 [OK] "echo 'a'*"
#10 [OK] "echo *$NOTHING"
#11 [OK] "echo $NOTHING*"
#12 [OK] "ls | cat -e && gcc -v || echo "$TERM""
[ shell output ]
42
[ bash output ]
42
[ diff ]
shell exit status = 0
bash exit status = 0
- Syntax rules for parser is defined as form of BNF in
bnf.md
. - Grammar reference
- Token recognition reference