Browse Source

TO-DO list added, fixed empty line, rm useless sig msg

master
Michael Ea 3 years ago
parent
commit
4b0afb250a
  1. 12
      README.md
  2. 16
      minishell.c
  3. 6
      utils.c

12
README.md

@ -3,10 +3,16 @@
## TODO : ## TODO :
- free stack, - free stack,
- finish built-ins, - protect mallocs,
- Norminette
- Finish check_builtin();
## Notes : - export : edit datas->env
- unset : idem,
- exit: handle arguments
- setup correct ext_codes
https://wiki.bash-hackers.org/scripting/basics?s[]=variables#exit_codes
## Issues : ## Issues :
- cat | cat | ls crash on linux ?

16
minishell.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ /* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */ /* Created: 2022/05/02 12:14:09 by narnaud #+# #+# */
/* Updated: 2022/05/05 15:31:45 by mea ### ########.fr */ /* Updated: 2022/05/05 16:28:15 by mea ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,13 +16,9 @@ void handle_status(t_datas *datas, int status)
{ {
if (WIFSIGNALED(status)) if (WIFSIGNALED(status))
{ {
datas->exit_code = WTERMSIG(status); datas->exit_code = 128 + WTERMSIG(status);
if (datas->exit_code == 3) if (datas->exit_code == 131)
printf("Quit: 3\n"); printf("Quit: 3\n");
if (datas->exit_code == 9)
printf("Kill: 15\n");
if (datas->exit_code == 15)
printf("Terminated: 15\n");
} }
else else
datas->exit_code = WEXITSTATUS(status); datas->exit_code = WEXITSTATUS(status);
@ -40,7 +36,8 @@ int caller(t_datas *datas, t_command *cmd)
cmd->fd[1] = pip[1]; cmd->fd[1] = pip[1];
cmd->next->fd[0] = pip[0]; cmd->next->fd[0] = pip[0];
} }
if (!cmd->prev && !cmd->next && command_call(datas, cmd) != -1)
if (!cmd->prev && !cmd->next && command_call(datas, cmd) != -1)//check_builtin(cmd->argv[0]))
return (1); return (1);
pid = fork(); pid = fork();
if (!pid) if (!pid)
@ -108,10 +105,7 @@ t_token *lexer(t_datas *datas, char *line)
if (check_state(lex, &line)) if (check_state(lex, &line))
continue; continue;
if (lex->state != S_QUOTE_ST && *line == '$') if (lex->state != S_QUOTE_ST && *line == '$')
{
tmp_i = replace_var(datas, &line, tmp, tmp_i); tmp_i = replace_var(datas, &line, tmp, tmp_i);
printf("TEST tmpi %d\n", tmp_i);
}
if (check_register(lex, &line, tmp)) if (check_register(lex, &line, tmp))
{ {
tmp_i = 0; tmp_i = 0;

6
utils.c

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* utils.c :+: :+: :+: */ /* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ /* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/03 08:57:53 by narnaud #+# #+# */ /* Created: 2022/05/03 08:57:53 by narnaud #+# #+# */
/* Updated: 2022/05/05 09:18:28 by narnaud ### ########.fr */ /* Updated: 2022/05/05 16:33:21 by mea ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,7 +16,7 @@ int is_empty(char *line)
{ {
while (*line) while (*line)
{ {
if (*line <= 9 || (*line >= 13 && *line != 32)) if (*line < 9 || (*line > 13 && *line != 32))
return (0); return (0);
line++; line++;
} }

Loading…
Cancel
Save