Small Unix-like shell in C.
- Batch mode: run shell with a script file argument.
- Logical operators: short-circuit execution for
&&and||. - Aliases: define, override, recursive expansion, loop protection.
- History navigation:
Up/Downarrows recall previous/next commands.
Other supported behavior:
cd,PWD/OLDPWD,jobs, pipes, redirection, background jobs, Ctrl+C/Ctrl+D handling.
- Linux environment (WSL recommended on Windows)
gcc,make,python3
Optional:
valgrind
If you are in Windows PowerShell:
wsl
cd /mnt/d/Desktop/CustomShell\ -\ Copy
make -BIf you are already inside WSL terminal, do not type wsl again:
cd /mnt/d/Desktop/CustomShell\ -\ Copy
make -BRun shell:
./bin/customShellRun batch mode:
./bin/customShell /path/to/script.txtcat >/tmp/batch_test.txt <<"EOF"
echo one
echo two
echo three
EOF
./bin/customShell /tmp/batch_test.txtExpected: prints one, two, three and exits.
shell208> true && echo AND_OK
shell208> false && echo SHOULD_NOT_PRINT
shell208> true || echo SHOULD_NOT_PRINT
shell208> false || echo OR_OK
shell208> false && echo NOPE || echo Done
Expected: AND_OK, OR_OK, Done; no SHOULD_NOT_PRINT, no NOPE.
shell208> alias l='echo LS -l'
shell208> l -a
shell208> alias a='b'
shell208> alias b='a'
shell208> a
Expected: LS -l -a is printed; alias loop is detected and shell does not hang.
shell208> env | grep PWD
shell208> cd /tmp
shell208> env | grep PWD
shell208> cd -
Expected: PWD and OLDPWD update correctly.
shell208> sleep 5
(press Ctrl+C)
shell208> sleep 3 &
shell208> jobs
shell208> sleep 4
shell208> jobs
Expected: foreground sleep is interrupted; background sleep shows Running then Done.
shell208> echo first
shell208> echo second
(press Up) -> shows: echo second
(press Up) -> shows: echo first
(press Down) -> shows: echo second
Expected: Up/Down cycles command history without retyping.
Run all test files:
python3 tests/python/test_all.pyOr discovery mode:
python3 -m unittest discover -s tests/python -p "test_*.py" -vRun each feature test file:
- Batch mode:
python3 tests/python/test_batch_mode.py - Logical operators:
python3 tests/python/test_logical_operations.py - Aliases:
python3 tests/python/test_aliases.py - CD, PWD, OLDPWD:
python3 tests/python/test_cd_pwd_oldpwd.py - Ctrl+C behavior:
python3 tests/python/test_ctrl_c.py - Background jobs:
python3 tests/python/test_background_jobs.py
make clean