How to implement simple shell, unix programming sandbox
Another snippet from Unix Sandbox. Do You want to write Your own shell? Maybe fork this code and improve it. Here is only basic concept. The main thing to improve is tokenizer for arguments. Adding history of commands is also a good idea.
What's done?
- CTRL+Z sigaction exit
- Main flow of fork and exec*
- Some hardcore tokenizer for 4 arguments (+ command)
But be aware, it's only for fun :)
https://github.com/khipis/c-unix-sandbox/blob/master/shell-terminal/shell.c
What's done?
- CTRL+Z sigaction exit
- Main flow of fork and exec*
- Some hardcore tokenizer for 4 arguments (+ command)
But be aware, it's only for fun :)
666:>ls -l -rw-r--r-- 1 root root 12315 lut 15 17:53 CMakeCache.txt drwxr-xr-x 5 root root 4096 lut 15 18:10 CMakeFiles -rw-r--r-- 1 root root 1433 lut 13 08:25 cmake_install.cmake -rw-r--r-- 1 root root 80 lut 15 17:54 cmdhist -rw-r--r-- 1 root root 5084 lut 15 17:53 Makefile -rwxr-xr-x 1 root root 18194 lut 15 18:10 shell_terminal -rw-r--r-- 1 root root 5458 lut 15 17:53 shell_terminal.cbp 666:>pwd /root/.CLion12/system/cmake/generated/90867f26/90867f26/Debug 666:>asd sHELL unknown command 666:>If You don't know how to start check it out:
https://github.com/khipis/c-unix-sandbox/blob/master/shell-terminal/shell.c
Komentarze
Prześlij komentarz