maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
echo.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* echo.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: dmdemirk <dmdemirk@student.42london.c +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/06/03 16:31:33 by dmdemirk #+# #+# */
9/* Updated: 2024/08/28 14:20:26 by dmdemirk ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14#include "shell.h"
15#include "exit_status.h"
16
17/*
18 Functionality:
19 - Print the argument
20*/
21
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}
int builtin_echo(t_ms_data *data)
Definition echo.c:22
#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