0922 - tamagoyakii/minishell GitHub Wiki
์ฐ๊ฒฐ ๋ฆฌ์คํธ๋ก ๋ณ๊ฒฝ
- ํ์ฑ ๋จ๊ณ์์ ๊ตฌํ ๋จ๊ณ๋ก ๋๊ฒจ์ฃผ๋ ๊ตฌ์กฐ์ฒด
typedef enum e_redir_type
{
INPUT, /* > */
OUTPUT, /* < */
A_OUTPUT, /* >> */
HEREDOC /* << */
} t_redir_type;
typedef struct s_redir
{
int r_type; /* redirect : >, <, >> | heredoc : << */
char *value; /* redirect : filename | heredoc : endstr */
struct s_redir *next;
} t_redir;
/* ๊ตฌํ๋ถ๋ก ๋๊น */
typedef struct s_argv
{
char **cmd; /* execve()๊ฐ ์ด์คํฌ์ธํฐ๋ฅผ ๋ฐ๊ธฐ ๋๋ฌธ์ */
struct s_redir *in;
struct s_redir *out;
struct s_argv *next;
} t_argv;
- ํ ํฐ ๊ด๋ จ ๊ตฌ์กฐ์ฒด
typedef enum e_token_type
{
WORD,
REDIR,
PIPE,
NULL
} t_token_type;
typedef struct s_token
{
int t_type;
char *str;
} t_token;
- ํ๊ฒฝ๋ณ์ ๊ตฌ์กฐ์ฒด
typedef struct s_env
{
char *key;
char *value;
struct s_env *prev;
struct s_env *next;
} t_env;
=> ํ๋ก๊ทธ๋จ ์คํ๊ณผ ๋์์ ์ด๊ธฐํํ์ฌ ์ฌ์ฉ
- ์ด๊ธฐํ
// wochae
- ํ๊ฒฝ ๋ณ์ ์ด๊ธฐํ ๋ฐ ์ ์ฅ
- ๊ตฌ์กฐ์ฒด ์ด๊ธฐํ
- ์ฌ์ฉ์ ์
๋ ฅ ์ฒ๋ฆฌ(Read Input)
// wochae
- ๋ฌธ์์ด ์ ๋ ฅ
- ์ ๋ ฅ๊ฐ ์ ํจ์ฑ ๊ฒ์ฌ
- ํ๊ฒฝ๋ณ์ ์นํ(Replace env)
// wochae
- ํ๊ฒฝ๋ณ์ ์นํ
- ๋ฌธ์์ด ๋ถํ (Split Line)
// donghyuk
- ๋งจ ์ ๊ณต๋ฐฑ ์ ๊ฑฐ
- quotes, double quotes ์ ๊ฑฐ + unclosed ์ฌ๋ถ ํ์ธ
- ์ด์ค ๋ฐฐ์ด ์์ฑ
- ํ ํฐ ์์ฑ(Create token)
// jihyukim
- ํ ํฐ ๋ฆฌ์คํธ ์์ฑ(type ์ ์, str ํ ๋น)
- ํ ํฐ ์ ํจ์ฑ ๊ฒ์ฌ(redirection, pipeline unclosed ์ฌ๋ถ ํ์ธ)
- ์ธ์ ์์ฑ(Create Argvs)
// jihyukim
- ํ ํฐ์ ์๋ง๊ฒ ํ ๋น
- wochae -> donghyuk :
char *replace_env()
- donghyuk -> jihyukim :
char **split_input()
- ๋ฉ์ธ ํ๋ก์ธ์ค์์ ์คํ
- ๋ฌด์จ ๋ช ๋ น์ด์ธ์ง ๊ฒ์ฌ(cmd[0] ํ์ธ)
- ์คํ
- ํ์ดํ ๊ฐ์ ํ์ธ
- while ๋๋ฉด์ ํ์ดํ ๊ฐ์๋งํผ ํ์ดํ ํจ์ ์คํ
- ํฌํฌ ์คํ
- ์์ ํ๋ก์ธ์ค ์๊ทธ๋ ์ค์ ํ์ํ๊ฐ? โ ํ์ํ๋ค
- ์์ฐ๋ fd ๋ซ์์ฃผ๊ธฐ
- ์์ ํ๋ก์ธ์ค ๋ค์ด๊ฐ์ in, out ๋ฐ๋ผ๊ฐ๋ฉด์ ํ์ผ ์์ฑ
- ํ์ดํ์ ๋ฐ๋ผ fd ์ค์
- ํ์ผ next๊ฐ ์๋ ๊ฒฝ์ฐ์๋ง infile fd, outfile fd๋ก ์ค์
- ํ์ผ next๊ฐ ์๋ ๊ฒฝ์ฐ fd close
- heredoc์ ๋ง์ง๋ง์ธ์ง ์๋์ง ์ฒดํฌํด์ ๋ง์ง๋ง์ด๋ฉด ์ ์ฅํ๊ณ ์๋๋ฉด ๋ง๊ณ (์์ํ์ผ ์์ฑ์ ๋ง์ง๋ง์ผ ๋๋ง)
- ์คํํ๊ธฐ
- ํ๋ก์ธ์ค ๊ธฐ๋ค๋ ค์ exit status ์ค์
- ๋ฐ์ ์ธ์ ํ๋ฆฌํด์ฃผ๊ธฐ
- single_builtin์ธ ๊ฒฝ์ฐ infile์ ์ฐพ์ ์ ์๋ค๋ฉด return์์ผ์ฃผ๋ ๋ถ๋ถ
- heredoc ๋ถ๋ถ
- wait, exit status ๋ถ๋ถ
- free ํจ์๋ค
- exceve ํจ์ PATH ์ฐพ๋ ๋ถ๋ถ
- builtin ํจ์ ์ ๋ถ ๋ค
- ์ฃผ๋ง ์ ๊น์ง
-
nheo
: ์ ์ฒด์ ์ธ ํ๋ฆ ์ฝ๋ฉ -
jabae
: pipe ๊ณต๋ถ,nheo
์ฝ๋ ํ ๋๋ก ํ๋ก์ฐ ์ฐจํธ ์ง๊ธฐ
- ์ฃผ๋ง ๋์
- built-in ํจ์ ๋๋ ์ ๊ตฌํํ๊ธฐ