maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
echo.c File Reference
#include "libft.h"
#include "shell.h"
#include "exit_status.h"
Include dependency graph for echo.c:

Go to the source code of this file.

Functions

int builtin_echo (t_ms_data *data)
 

Function Documentation

◆ builtin_echo()

int builtin_echo ( t_ms_data data)

Definition at line 22 of file echo.c.

23{
24 int newline;
25 int i;
26
27 newline = 1;
28 if (data->args[1] && (ft_strcmp(data->args[1], "-n") == 0))
29 {
30 newline = 0;
31 data->args++;
32 }
33 i = 0;
34 while (data->args[++i])
35 {
36 ft_putstr_fd(data->args[i], STDOUT_FILENO);
37 if (data->args[i + 1])
38 ft_putstr_fd(" ", STDOUT_FILENO);
39 }
40 if (newline)
41 write(STDOUT_FILENO, "\n", 1);
42 return (EXIT_SUCCESS);
43}
#define EXIT_SUCCESS
Definition exit_status.h:16
int ft_strcmp(const char *s1, const char *s2)
Definition ft_strcmp.c:24
void ft_putstr_fd(char *s, int fd)
char ** args
Definition shell.h:23

References s_ms_data::args, EXIT_SUCCESS, ft_putstr_fd(), and ft_strcmp().

Referenced by execute().

Here is the call graph for this function:
Here is the caller graph for this function: