Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug : #53/선언되지 않은 환경변수 에러 #55

Merged
merged 2 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions execute/child.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: wonyang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/11 23:33:05 by wonyang #+# #+# */
/* Updated: 2023/01/14 12:53:27 by wonyang ### ########seoul.kr */
/* Updated: 2023/01/14 22:34:33 by wonyang ### ########seoul.kr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -34,6 +34,7 @@ static t_error child_execve(t_tnode *node, char *path, char **argv)
if (is_builtin_cmd(node) == true)
exit(builtin_execve(builtin, argv, &(g_var.envp), 1));
execve(path, argv, g_var.envp.arr);
exit(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에 exit(0)을 추가한 이유가 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로직대로라면 실행될 일이 없겠지만, 이번 이슈 같은 상황을 방지하기 위해 추가했습니다.
무한루프 걸리는 상황보다는 그냥 종료되는게 안전하니까요 😢

return (ERROR);
}

Expand All @@ -50,9 +51,12 @@ static t_error child_execute(t_tnode *cmd_node)
ft_freesplit(cmd_argv);
return (ERROR);
}
if (is_builtin_cmd(cmd_node) == false && !path)
if (ft_strcmp(cmd_argv[0], "") == 0
|| (is_builtin_cmd(cmd_node) == false && !path))
{
perror("command not found");
ft_putstr_fd("bash: ", STDERR_FILENO);
ft_putstr_fd(cmd_argv[0], STDERR_FILENO);
ft_putendl_fd(": command not found", STDERR_FILENO);
exit(127);
}
if (apply_redirections(cmd_node) == ERROR
Expand Down
4 changes: 2 additions & 2 deletions execute/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: wonyang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/11 17:19:11 by wonyang #+# #+# */
/* Updated: 2023/01/13 15:22:10 by wonyang ### ########seoul.kr */
/* Updated: 2023/01/14 22:33:47 by wonyang ### ########seoul.kr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -88,7 +88,7 @@ t_error make_cmd_path(char *cmd_name, char **path, char **envp)
*path = NULL;
if (access(cmd_name, X_OK) == 0)
{
*path = cmd_name;
*path = ft_strdup(cmd_name);
return (SCS);
}
path_list = parse_paths(envp);
Expand Down