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 "execute.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 23 of file echo.c.

24{
25 int newline;
26 int i;
27 char **args;
28
29 newline = 1;
30 i = 1;
31 args = data->args;
32 if (!data || !data->args || !data->args[0])
33 return (EXIT_FAILURE);
34 handle_std_io(&data->std_out, STDOUT_FILENO);
35 if (args[1] && ft_strcmp(args[1], "-n") == 0)
36 {
37 newline = 0;
38 i = 2;
39 }
40 while (args[i])
41 {
42 ft_putstr_fd(args[i], STDOUT_FILENO);
43 if (args[i + 1])
44 ft_putstr_fd(" ", STDOUT_FILENO);
45 i++;
46 }
47 if (newline)
48 ft_putchar_fd('\n', STDOUT_FILENO);
49 return (EXIT_SUCCESS);
50}
void handle_std_io(int *std_io, int std_fileno)
Definition utils_0.c:50
#define EXIT_SUCCESS
Definition exit_status.h:16
#define EXIT_FAILURE
Definition exit_status.h:17
int ft_strcmp(const char *s1, const char *s2)
Definition ft_strcmp.c:24
void ft_putchar_fd(char c, int fd)
void ft_putstr_fd(char *s, int fd)
int std_out
Definition shell.h:27
char ** args
Definition shell.h:23

References s_ms_data::args, EXIT_FAILURE, EXIT_SUCCESS, ft_putchar_fd(), ft_putstr_fd(), ft_strcmp(), handle_std_io(), and s_ms_data::std_out.

Referenced by execute().

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