Командна оболонка Unix мовою С
У рамках навчання в школі 42 я реалізував проєкт операційної системи, що включав в себе створення інтерпретатора команд Unix мовою C. Цей проєкт, 42sh, є реалізацією ще десятка інших проєктів, що здійснювалися в логічній послідовності та затверджувалися від кількох тижнів до кількох місяців кожен.
LВикористання бібліотек C було обмеженим, а правила компіляції та стандарти програмування були суворими. Наша команда з 3 студентів обрала Bash 5.0 в якості опорної оболонки і розробила наступні функціональні можливості:
- Execution of commands with their parameters and management of $PATH
- Error handling and return value
- Complete command line editing
- Dynamic and contextual completion of commands, built-ins, files and variables
- Inhibitors :
- ’ single quote
- ” double quote
- \ backslash
- Logical operators :
- &&
- ||
- Redirect operators :
- >
- >>
- <
- <<
- <<<
- >&
- <&
- |
- The separator ;
- Management of all signals
- Program suspension by the operator & as well as the built-ins :
- jobs
- fg
- bg
- Integration of internal variables with :
- creation with syntax var=value
- display with buit-in set
- revocation with the built-in unset (internal and environment variable)
- export with built-in export
- Alias support with built-ins alias and unalias
- Optimizing the search for binaries by a hash table accessible by the built-in hash
- As well as the following built-ins :
- cd
- echo
- type
- test
- exit
All the buit-ins respect the standard POSIX except set, unset and test.
Only the following functions were imported from the C libraries:_access
_chdir
_close
_closedir
_dup
_dup2
_environ
_execve
_exit
_fork
_free
_getcwd
_getenv
_getpgrp
_getpid
_getpwnam
_getpwuid
_getuid
_ioctl
_isatty
_kill
_lstat
_malloc
_memcpy
_nanosleep
_open
_opendir
_pipe
_read
_readdir
_setpgid
_signal
_stat
_tcgetattr
_tcgetpgrp
_tcsetattr
_tcsetpgrp
_tgetent
_tgetstr
_tgoto
_tputs
_uname
_unlink
_waitpid
_write
Description
42
Може 2019
Створення оболонки Unix мовою C з мінімумом бібліотек і максимумом функціональних можливостей. Результат, схожий на bash 5.0.