μλ§νΌμ΄λ μλ¦λ€μ΄ κ·Έκ²
Summary: The objective of this project is for you to create a simple shell. Yes, your own little bash or zsh. You will learn a lot about processes and file descriptors.
μμ½: μ΄λ² νλ‘μ νΈμ λͺ©νλ κ°λ¨ν μμ λ§λλ κ²μ λλ€. λ§μμ, λΉμ λ§μ μμ bashλ zshμ΄μ. νλ‘μΈμ€λ νμΌ λμ€ν¬λ¦½ν°μ λν΄ μμ£Ό λ§μ΄ λ°°μ°κ² λ κ²λλ€.
| Chapter | Contents | page |
|---|---|---|
| I | Introduction | 2 |
| II | Common Instructions | 3 |
| III | Mandatory part | 4 |
| IV | Bonus part | 6 |
The existence of shells is linked to the very existence of IT. At the time, all coders agreed that communicating with a computer using aligned 1/0 switches was seriously irritating. It was only logical that they came up with the idea to communicate with a computer using interactive lines of commands in a language somewhat close to english.
μμ ITμ νμ΄λΆν° ν¨κ»νμ΅λλ€. κ·Έ λΉμ, λͺ¨λ κ°λ°μλ€μ 1κ³Ό 0μΌλ‘λ§ μ΄λ£¨μ΄μ§ μ€μμΉλ‘ μ»΄ν¨ν°μ ν΅μ νλ κ²μ κ΅μ₯ν μ±κ°μλ€λ μ μ λμνμ΄μ. κ·Έλ¦¬κ³ μμ΄μ λΉμ·ν μΈμ΄λ‘ μμ±λ λͺ
λ Ήμ΄μ μ€μ μ΄μ©ν΄ μ»΄ν¨ν°μ μν΅νλ€λ μμ΄λμ΄λ₯Ό λ μ¬λ¦° κ²λ λΉμ°ν μμμ΄μμ£ .
With Minishell, youβll be able to travel through time and come back to problems people faced when Windows didnβt exist.
Minishellκ³Ό ν¨κ»λΌλ©΄, Windowsκ° μ‘΄μ¬νμ§ μμμ μμ μ¬λλ€μ΄ κ²ͺμλ λ¬Έμ λ₯Ό λ§μ£Όν΄λ³Ό μ μμ κ²λλ€.
-
Your project must be written in accordance with the Norm. If you have bonus files/functions, they are included in the norm check and you will receive a 0 if there is a norm error inside.
νλ‘μ νΈλ Norm κ·μΉμ λ§μΆ° μμ±λμ΄μΌ ν©λλ€. 보λμ€ νμΌ/ν¨μκ° μ‘΄μ¬ν κ²½μ°, κ·Έ λν norm κ²μ¬μ ν¬ν¨λλ©° norm errorκ° μμ μ 0μ μ λ°κ² λ©λλ€.
-
Your functions should not quit unexpectedly (segmentation fault, bus error, double free, etc) apart from undefined behaviors. If this happens, your project will be considered non functional and will receive a 0 during the evaluation.
μ μλμ§ μμ λμμ μ μΈνκ³ , μ¬λ¬λΆμ΄ μμ±νμ νλ‘κ·Έλ¨μ΄ μκΈ°μΉ μκ² μ€λ¨λμ΄μλ μ λ©λλ€. (μλ₯Ό λ€μ΄, segmentation fault, bus error, double free λ±) λ§μ½ μ¬λ¬λΆμ νλ‘κ·Έλ¨μ΄ μκΈ°μΉ μκ² μ’ λ£λλ€λ©΄, μ λλ‘ μλνμ§ μμ κ²μΌλ‘ κ°μ£Όλμ΄ νκ°μμ 0μ μ λ°κ² λ©λλ€.
-
νμν κ²½μ° heapμ ν λΉλ λͺ¨λ λ©λͺ¨λ¦¬ 곡κ°μ μ μ νκ² ν΄μ λμ΄μΌ ν©λλ€. λ©λͺ¨λ¦¬ λμλ μ©λ©λ μ μμ΅λλ€.
-
If the subject requires it, you must submit a Makefile which will compile your source files to the required output with the flags -Wall, -Wextra and -Werror, and your Makefile must not relink.
κ³Όμ μμ νμν κ²½μ°, -Wall -Wextra -Werror νλκ·Έλ₯Ό μ§μ νμ¬ μ»΄νμΌμ μννλ Makefileμ μ μΆν΄μΌ ν©λλ€. Makefileμ relink λμ΄μλ μ λ©λλ€.
-
Makefileμ μ΅μν $(NAME), all, clean, fclean, re κ·μΉμ ν¬ν¨ν΄μΌ ν©λλ€.
-
To turn in bonuses to your project, you must include a rule bonus to your Makefile, which will add all the various headers, librairies or functions that are forbidden on the main part of the project. Bonuses must be in a different file _bonus.{c/h}. Mandatory and bonus part evaluation is done separately.
νλ‘μ νΈμ 보λμ€λ₯Ό μ μΆνλ €λ©΄, Makefileμ 보λμ€ κ·μΉμ ν¬ν¨ν΄μΌ ν©λλ€. μ΄ λ³΄λμ€ κ·μΉμ νλ‘μ νΈμ λ©μΈ ννΈμμ κΈμ§λμλ λͺ¨λ λ€μν ν€λ, λΌμ΄λΈλ¬λ¦¬, λλ ν¨μλ€μ μΆκ°νμ¬μΌ ν©λλ€. 보λμ€ κ³Όμ λ λ°λμ _bonus.{c/h}λΌλ λ³λμ νμΌμ μμ΄μΌ ν©λλ€. λ°λμ μννμ¬μΌ νλ λ©μΈ ννΈμ νκ°μ 보λμ€ ννΈμ νκ°λ λ³λλ‘ μ΄λ€μ§λλ€.
-
If your project allows you to use your libft, you must copy its sources and its associated Makefile in a libft folder with its associated Makefile. Your projectβs Makefile must compile the library by using its Makefile, then compile the project.
λ§μΌ νλ‘μ νΈμμ μ¬λ¬λΆμ libft μ¬μ©μ νμ©νλ€λ©΄, μμ€λ€κ³Ό κ΄λ ¨ Makefileμ ν¨κ» λ£¨νΈ ν΄λ μμ μλ libft ν΄λμ 볡μ¬ν΄μΌ ν©λλ€. νλ‘μ νΈμ Makefileμ μ°μ libftμ Makefileμ μ¬μ©νμ¬ λΌμ΄λΈλ¬λ¦¬λ₯Ό μ»΄νμΌν λ€μ, νλ‘μ νΈλ₯Ό μ»΄νμΌν΄μΌ ν©λλ€.
-
We encourage you to create test programs for your project even though this work wonβt have to be submitted and wonβt be graded. It will give you a chance to easily test your work and your peersβ work. You will find those tests especially useful during your defence. Indeed, during defence, you are free to use your tests and/or the tests of the peer you are evaluating.
μ΄ κ³Όμ λ¬Όμ μ μΆν νμκ° μκ³ , μ±μ λ°μ νμκ° μμμ§λΌλ, μ ν¬λ μ¬λ¬λΆλ€μ΄ νλ‘μ νΈλ₯Ό μν ν μ€νΈ νλ‘κ·Έλ¨μ λ§λ€ κ²μ κΆμ₯ν©λλ€. μ΄κ²μ μ¬λ¬λΆμ κ³Όμ λ¬Όκ³Ό λλ£λ€μ κ³Όμ λ¬Όμ μ½κ² ν μ€νΈν μ μκ² λμΈ κ²μ λλ€. λν, νκ°λ₯Ό μ§νν λ μ΄λ¬ν ν μ€νΈ νλ‘κ·Έλ¨λ€μ΄ νΉν μ μ©νλ€λ μ¬μ€μ μκ² λ κ²μ λλ€. νκ° μμλ μ¬λ¬λΆμ ν μ€νΈ νλ‘κ·Έλ¨κ³Ό νκ° λ°λ λλ£μ ν μ€νΈ νλ‘κ·Έλ¨λ€μ λΉμ°ν μμ λ‘κ² μ¬μ©ν μ μμ΅λλ€.
-
Submit your work to your assigned git repository. Only the work in the git repository will be graded. If Deepthought is assigned to grade your work, it will be done after your peer-evaluations. If an error happens in any section of your work during Deepthoughtβs grading, the evaluation will stop.
ν λΉλ git μ μ₯μμ κ³Όμ λ¬Όμ μ μΆνμΈμ. μ€μ§ git μ μ₯μμ μλ κ³Όμ λ¬Όλ§ λ±κΈμ΄ λ§€κ²¨μ§ κ²μ λλ€. Deepthoughtκ° νκ°νλ κ³Όμ μ κ²½μ°μ, λλ£νκ° μ΄νμ Deepthoughtκ° μνλ©λλ€. λ§μ½ Deepthought νκ° μ€μ μ€λ₯κ° λ°μνλ€λ©΄, κ·Έ μ¦μ νκ°λ μ€μ§λ κ²μ λλ€.
| νλ‘κ·Έλ¨ μ΄λ¦ | minishell |
| μ μΆν νμΌ | |
| Makefile | λ§λ€μ΄μΌ ν¨ |
| μΈμ | |
| μ¬μ©κ°λ₯ν μΈλΆ ν¨μ | readline, rl_on_new_line, rl_replace_line, rl_redisplay, add_history, printf, malloc, free, write, open, read, close, fork, wait, waitpid, wait3, wait4, signal, kill, exit, getcwd, chdir, stat, lstat, fstat, unlink, execve, dup, dup2, pipe, opendir, readdir, closedir, strerror, errno, isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr, tcgetattr, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs |
| μ§μ λ§λ libft | μ¬μ© κ°λ₯ |
| μ€λͺ | μμ λ§λμΈμ |
λΉμ μ μμ:
-
λ«νμ§ μμ λ°μ΄νλ νΉμ λμ§ μμ νΉμλ¬Έμ (\λ ; λ±...) μ ν΄μνμ§ μμμΌ ν©λλ€.
-
μ μλ³μλ ν κ° μ΄μμ μ¬μ©ν μ μμΌλ©°, μ μ μλ³μλ₯Ό μ¬μ©νλμ§ κΉκ² μκ°ν΄ λ³΄κ³ κ·Έ μ΄μ λ₯Ό μ€λͺ ν μ μμ΄μΌ ν©λλ€.
-
μλ‘μ΄ λͺ λ Ήμ΄λ₯Ό μ λ ₯ν μ μλ ν둬ννΈλ₯Ό 보μ¬μ€μΌ ν©λλ€.
-
μμ νμ€ν 리λ₯Ό κ°κ³ μμ΄μΌ ν©λλ€.
-
Search and launch the right executable (based on the PATH variable or by using relative or absolute path)
(PATH λ³μλ μλ, μ λ κ²½λ‘λ₯Ό νμ©νμ¬) μ¬λ°λ₯Έ μ€ν νμΌμ μ°Ύμ μ€νν μ μμ΄μΌ ν©λλ€.
-
λ€μμ λ΄μ₯ κΈ°λ₯μ μ€νν μ μμ΄μΌ ν©λλ€:
-
-nμ΅μ μ μ¬μ©ν μ μλecho -
μ€μ§ μλ λλ μ λκ²½λ‘λ§ μ¬μ©νλ
cd -
μ΅μ μ΄ μλ
pwd -
μ΅μ μ΄ μλ
export -
μ΅μ μ΄ μλ
unset -
μ΅μ μ΄λ μΈμκ°μ΄ μλ
env -
μ΅μ μ΄ μλ
exit
-
-
'λ μΌλ ¨μ λ¬Έμμ΄μ λν ν΄μμ κΈμ§ν©λλ€. -
"λ$λ₯Ό μ μΈν λͺ¨λ λ¬Έμμ΄μ λν ν΄μμ κΈμ§ν©λλ€. -
리λ€μ΄λ μ :
-
<λ μ λ ₯μ 리λ€μ΄λ μ νμ¬μΌ ν©λλ€ -
>λ μΆλ ₯μ 리λ€μ΄λ μ νμ¬μΌ ν©λλ€ -
<<read input from the current source until a line containing only the delimiter is seen. it doesnβt need to update history!<<λ νμ¬ μμ€μμ ꡬλΆμλ₯Ό ν¬ν¨ν μ€μ λ§λκΈ° μ κΉμ§ μ λ ₯κ°μ μ½μ΄λ€μ λλ€. κΈ°λ‘μ μ λ°μ΄νΈν νμλ μμ΅λλ€! -
>>λ μΆλ ₯μ μΆκ° λͺ¨λλ‘ λ¦¬λ€μ΄λ μ ν©λλ€.
-
-
Pipes | The output of each command in the pipeline is connected via a pipe to the input of the next command.
νμ΄ν
|: κ° νμ΄νλΌμΈλ§λ€ λͺ λ Ήμ΄μ μΆλ ₯κ°μ νμ΄νλ‘ μ°κ²°λμ΄ λ€μ λͺ λ Ήμ΄μ μ λ ₯κ°μΌλ‘ λ€μ΄κ°μΌ ν©λλ€. -
νκ²½ λ³μ ($ λ€μμ λ¬Έμμ΄μ΄ μ€λ νμ) μ κ·Έλ€μ κ°μΌλ‘ νμ₯λμ΄μΌ ν©λλ€.
-
$?λ κ°μ₯ μ΅κ·Όμ μ€νν ν¬κ·ΈλΌμ΄λ νμ΄νλΌμΈμ μ’ λ£ μνλ₯Ό νμ₯νμ¬μΌ ν©λλ€ -
ctrl-C,ctrl-D,ctrl-\λ bashμ λμΌνκ² λμνμ¬μΌ ν©λλ€. -
μνΈμμ©μ΄ κ°λ₯ν λ:
-
ctrl-Cλ μλ‘μ΄ μ€μ μλ‘μ΄ ν둬ννΈλ₯Ό μΆλ ₯ν©λλ€ -
ctrl-Dλ μμ μ’ λ£ν©λλ€. -
ctrl-\μ μλ¬΄λ° λμλ νμ§ μμ΅λλ€.
-
μꡬνμ§ μμ κ²λ€μ λ§λμ€ νμλ μμ΅λλ€.
κ³Όμ μ μ΄λ ν μ§μ μμλ , μλ¬Έμ μ΄ μκΈ΄λ€λ©΄ bashλ₯Ό μ°Έκ³ νμΈμ.
-
νμ ννΈκ° μλ²½νμ§ μμΌλ©΄ 보λμ€λ μκ°νμ§λ λ§μΈμ.
-
κ΄νΈλ₯Ό μ΄μ©ν΄ μ°μ μμλ₯Ό ννν
&&, || -
μμΌλμΉ΄λ
*κ° νμ¬ μμ λλ ν 리μ λν΄ λμνμ¬μΌ ν©λλ€.