now it works
This commit is contained in:
parent
5ad220e434
commit
5e89605f63
@ -12,6 +12,22 @@
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
static int is_n_flag(char *cmd)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (cmd[0] != '-')
|
||||
return (0);
|
||||
i = 1;
|
||||
while (cmd[i])
|
||||
{
|
||||
if (cmd[i] != 'n')
|
||||
return (0);
|
||||
i++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int builtin_echo(t_minishell *msh, t_command *cmd)
|
||||
{
|
||||
int i;
|
||||
@ -20,14 +36,14 @@ int builtin_echo(t_minishell *msh, t_command *cmd)
|
||||
(void)msh;
|
||||
i = 1;
|
||||
n_flag = 0;
|
||||
if (cmd->args[i] != NULL && ft_strncmp(cmd->args[i], "-n", 2) == 0)
|
||||
if (cmd->args[i] != NULL && is_n_flag(cmd->args[i]))
|
||||
{
|
||||
n_flag = 1;
|
||||
i++;
|
||||
}
|
||||
while (cmd->args[i] != NULL)
|
||||
{
|
||||
while (ft_strncmp(cmd->args[i], "-n", 2) == 0 && n_flag > 0)
|
||||
while (is_n_flag(cmd->args[i]) && n_flag > 0)
|
||||
i++;
|
||||
printf("%s", cmd->args[i]);
|
||||
if (cmd->args[i + 1] != NULL)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user