42_minishell's Introduction
42_minishell's People
42_minishell's Issues
[FIX] unset 함수도 환경변수 없으면 터짐
t_env *make_envlist(char **env)
{
int i;
t_env *env_list;
i = -1;
env_list = NULL;
while (env[++i])
{
if (ft_strncmp(env[i], "OLDPWD", 6) == 0)
continue ;
// env_pushback(&env_list, env_createnew(env[i])); << 환경변수 날린거임
}
return (env_list);
}
pmshell> :$ unset a
[1] 36796 segmentation fault ./minishell
이것도 터져요 by 장민석
pmshell> :$ env
pmshell> :$ export a=b
pmshell> :$ env
pmshell> :$
이건 왜 안들어가요 by 고지흔
pmshell> :$ export
[1] 38544 segmentation fault ./minishell
ㅋㅋ 이것도 터지는데? by 고지흔
[FIX] readline에서 SIGINT가 들어오면 status_code가 변화하지 않습니다
readline에서 SIGINT가 들어오면 status_code가 변화하지 않습니다.
readline에서 SIGINT가 들어오면 해당 SIGNAL에 추가적으로 다른 숫자를 더해야합니다.
이 이슈는 #27 이거랑 같이 하면 될것 같습니다.
[FIX] g_status_code 전역 변수를 지역 변수로 옮김
minishell에서 전역 변수는 signal handle을 위해서 사용해야 하기 때문에 exit code를 위해서 사용되는 g_status_code는 전역 변수로 사용할 수 없습니다. 따라서 이 변수를 지역 변수로 옮깁니다.
전역 변수는 signal handler 함수에서 g_signo 를 signo로 덮어씌워서 사용하는게 좋을것 같습니다.
[FIX] exit할 때 heredoc이 안사라짐
exit함수를 다시 만들어야 할것 같습니다
<< a exit
이거하면 0.tmp가 안사라져요
[FIX] NORM 맞추기
파일의 NORM을 맞춰주세요
[FIX] Value가 없는 ENV 변수 관련 Segmentation Fault
Summary
Value가 정의되지 않은 ENV 변수에서 Segmentation Fault가 발생합니다.
Description
export asdf
와 같이 Value가 정의되지 않은 ENV 변수 호출 시 ($asdf
) Segmentation Fault가 발생합니다.
[FIX] cd 관련 오류 다수 발견
pmshell> :$ mkdir testf
mkdir: testf: File exists
pmshell> :$ cd testf
/Users/sangyleepmshell> :$ rm -rf ../testf
pmshell> :$ cd
/Users/sangyleeAddressSanitizer:DEADLYSIGNAL
int cmd_cd(char **argv, t_env *env_list)
{
char *home_path;
char *new_path;
char *prev_path;
home_path = get_home_path(env_list);
fprintf(stderr, "%s", home_path);
if (argv[1] == NULL || argv[1][0] == '~')
{
if (argv[1] == NULL)
new_path = ft_strdup(home_path);
else
new_path = ft_strjoin(home_path, &argv[1][1]);
}
else if (ft_strcmp(argv[1], "-") == 0)
new_path = get_oldpwd(env_list);
else
new_path = ft_strdup(argv[1]);
if (new_path == NULL)
return (0);
prev_path = getcwd(NULL, 0);
if (chdir(new_path) != 0
|| !update_pwd(env_list) <<<<<<<<<< 여기 문제임 with 고지흔
|| !update_oldpwd(ft_strjoin("OLDPWD=", prev_path), env_list))
{
four_times_free(prev_path, new_path, home_path, 0);
ft_putstr_fd("pmshell: ", 2);
perror("cd");
return (0);
}
four_times_free(prev_path, new_path, home_path, 0);
return (1);
}
폴더 만들고 폴더 안에 들어가서 폴더를 삭제하고 cd하니까 세그폴트 나요
2
t_env *make_envlist(char **env)
{
int i;
t_env *env_list;
i = -1;
env_list = NULL;
while (env[++i])
{
if (ft_strncmp(env[i], "OLDPWD", 6) == 0)
continue ;
// env_pushback(&env_list, env_createnew(env[i]));
}
return (env_list);
}
envlist를 안만들면 (모두 unset 한거임 by 고지흔)
pmshell> :$ pwd
/Users/sangylee/Desktop/pm_shell
pmshell> :$ ls
pmshell: ls: No such file or directory
pmshell> :$ ls
pmshell: ls: No such file or directory
pmshell> :$ PWD
pmshell: PWD: No such file or directory
pmshell> :$ cd
[1] 35755 segmentation fault ./minishell
명령어가 터져요
[DEV} HERE_DOC 처리 기능 구현
cmd_list에 heredoc이 들어오면 임시 파일을 생성해서 사용자가 입력한 값이 그곳에 들어갈 수 있는 기능을 구현합니다.
[FIX] OLDPWD를 초기 shell 실행 할때 env에 들어가 있는 문제 해결
OLDPWD를 초기 shell 실행 할때 env에 들어가 있는 문제를 해결하겠습니다
[FIX] Heredoc 입력 중 SIGINT 발생 시, 프로세스가 종료되는 현상
Summary
Heredoc 입력 과정에서 SIGINT가 발생하는 경우, 프로세스가 종료되는 현상이 있습니다.
Description
- Heredoc 입력 중, Ctrl+C 등의 방법으로 SIGINT를 발생시키는 경우,
minishell
프로세스 자체에 시그널이 전달되어 종료되는 문제가 있습니다.
[FIX] check_input에서 ctrl+D를 누르면 세그폴트 나는 현상 해결
check_input에서 ctrl+D를 누르면 세그폴트 나는 현상을 해결합니다.
ctrl+D를 누르면 input이 null이 되어서 생기는 현상이라서 파싱부에서 해결합니다.
[FIX] heredoc이 들어올 때 redirection io가 읽지 못하는 문제
static int redirect_input(t_redirect *redir, t_info *info)
{
int fd;
fd = open(redir->file, O_RDONLY);
if (fd == -1)
exit_err(redir->file, 1, info);
if (dup2(fd, STDIN_FILENO) == -1)
perror("dup2(stdin)");
close(fd);
return (1);
}
이 함수에서 redir->file이 redirection인 경우에는 deilmeter가 들어오기 때문에 현재 코드에서는 에러가 납니다
redirection인 경우에는 0.tmp, 1.tmp 등등으로 읽어야 합니다.
[DEV] env 구조체 구조 변경
env 구조체의 구조를 key-value가 아닌 단순 문자열로 변경합니다
거기에 해당 구조체에 맞는 구조를 변경합니다
[DEV] exit build command의 여러 경우의 수 고려 필요
현재 exit는 빌트인이 들어오면 exit(0)하고 마는데,
exit 1234
이렇게 들어오면 exit(1234)로 status code를 반환해야 합니다.
추가로 문자열은 어떻게 처리할지 알아서 하시면 됩니다.
결국 exit의 옵션을 추가해야 합니다.
[FIX] . 이나 /가 입력이 안되는 현상 해결
. 이나 /가 입력이 안되는 현상 해결 하러 가겠습니다
[DEV] waitpid를 할때 예외처리
void cmd_wait_child(pid_t pid_parent, int cmd_cnt)
{
int i;
int status;
int is_print_err;
pid_t pid_child;
i = 0;
is_print_err = 0;
while (i < cmd_cnt)
{
pid_child = waitpid(-1, &status, 0);
if (WIFSIGNALED(status) && ++is_print_err)
{
if (WTERMSIG(status) == SIGINT && is_print_err)
ft_putstr_fd("^C\n", STDERR_FILENO);
else if (WTERMSIG(status) == SIGQUIT && is_print_err)
ft_putstr_fd("^\\Quit: 3\n", STDERR_FILENO);
if (pid_child == pid_parent)
g_status_code = 128 + WTERMSIG(status);
}
else if (pid_child == pid_parent)
g_status_code = WEXITSTATUS(status);
i++;
}
}
이 함수에서 pid_child로 받는데, 파이프의 경우 맨 마지막에 실행이 종료되는 코드의 status code가 아닌, 파이프의 마지막에 위치한 pid의 status code를 받아와야 하기 때문에 맨 마지막 파이프의 pid를 가져야 합니다. 그것을 저장하는 로직을 구현해야 합니다.
[FIX] cd $HOME이 사라질때 에러 미시지 추가하기
cd ~의 원리가
$HOME을 찾고 그것의 값으로 이동하는데, unset으로 $HOME을 지우면 원래는 에러 메시지가 나와야 합니다.
그런데 현재는 그냥 아무것도 안나와서 그것을 수정해야합니다.
에러 메시지 고려 잘해주세요
[Feat] Tokenizer 구현
Tokenizer를 구현할게요
[FIX] Built-in return value가 반대로 되어있습니다.
정상 종료인 경우 return 0 해서 status code가 0이 되어야 하고,
에러가 나면 return 1해서 status code 가 1이 되어야 합니다. 이거 고쳐주세요
[FIX] exit code 맞추세요
exit code 귀찮다고 안맞추지 말고 고치세요
bash-3.2$ |
bash: syntax error near unexpected token `|'
bash-3.2$ $?
bash: 258: command not found
내것도 해줘
부탁임
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.