Browse Source

-fix: quotes after redir, exit with multiple args, return code save only on last pipe cmd

master
narnaud 3 years ago
parent
commit
d1d946315a
  1. 8
      built-in.c
  2. 4
      caller.c
  3. 4
      lexer.c

8
built-in.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ /* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/06 09:02:57 by narnaud #+# #+# */ /* Created: 2022/01/06 09:02:57 by narnaud #+# #+# */
/* Updated: 2022/05/16 10:48:07 by mea ### ########.fr */ /* Updated: 2022/05/16 11:55:41 by narnaud ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -94,9 +94,11 @@ int ft_cd(t_command *cmd)
int ft_exit(t_datas *datas, t_command *cmd) int ft_exit(t_datas *datas, t_command *cmd)
{ {
if (cmd->argc < 2) if (cmd->argc == 1)
halt(datas, EXIT_SUCCESS, 0); halt(datas, EXIT_SUCCESS, 0);
else else if (cmd->argc == 2)
halt(datas, ft_atoi(cmd->argv[1]), 0); halt(datas, ft_atoi(cmd->argv[1]), 0);
else
ft_putstr_fd("minishell: exit: too many arguments\n", 2);
return (1); return (1);
} }

4
caller.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ /* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */ /* Created: 2022/05/03 11:48:16 by narnaud #+# #+# */
/* Updated: 2022/05/16 10:42:40 by mea ### ########.fr */ /* Updated: 2022/05/16 11:57:13 by narnaud ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -119,9 +119,9 @@ int caller(t_datas *datas, t_command *cmd)
if (cmd->ope == PIPE) if (cmd->ope == PIPE)
caller(datas, cmd->next); caller(datas, cmd->next);
waitpid(cmd->pid, &status, 0); waitpid(cmd->pid, &status, 0);
datas->exit_code = handle_status(datas, status);
if (cmd->ope != PIPE) if (cmd->ope != PIPE)
{ {
datas->exit_code = handle_status(datas, status);
while (cmd->next && !((cmd->ope == AND && !datas->exit_code) \ while (cmd->next && !((cmd->ope == AND && !datas->exit_code) \
|| (cmd->ope == OR && datas->exit_code))) || (cmd->ope == OR && datas->exit_code)))
cmd = cmd->next; cmd = cmd->next;

4
lexer.c

@ -6,7 +6,7 @@
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ /* By: mea <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/02 13:44:57 by narnaud #+# #+# */ /* Created: 2022/05/02 13:44:57 by narnaud #+# #+# */
/* Updated: 2022/05/16 10:21:34 by mea ### ########.fr */ /* Updated: 2022/05/16 11:46:13 by narnaud ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,7 +31,7 @@ void tmp_dealer(t_datas *datas, t_lexer *lex, char *line, char *tmp)
} }
else if (check_register(lex, &line, tmp)) else if (check_register(lex, &line, tmp))
tmp_i = (ft_bzero(tmp, STR_MAX_SIZE), 0); tmp_i = (ft_bzero(tmp, STR_MAX_SIZE), 0);
else else if (!(lex->state == ROOT_ST && lex->deep == 0 && (*line == '"' || *line == '\'')))
tmp[tmp_i++] = *(line++); tmp[tmp_i++] = *(line++);
} }
} }

Loading…
Cancel
Save