MiniDevil As beautiful as a shell
builtin_echo.c File Reference

Implements echo: prints arguments with optional -n flag. More...

#include "builtins.h"
#include "libft.h"
+ Include dependency graph for builtin_echo.c:

Detailed Description

Implements echo: prints arguments with optional -n flag.

Definition in file builtin_echo.c.

Functions

static int is_n_flag (char *arg)
 Check if a given argument is a valid -n flag. More...
 
int builtin_echo (char **args)
 Implement the echo command. More...
 

Function Documentation

◆ is_n_flag()

static int is_n_flag ( char *  arg)
static

Check if a given argument is a valid -n flag.

A valid n flag starts with - followed by 1 or more n characters

Parameters
argArgument string to check
Returns
1 if valid and 0 if not

Definition at line 24 of file builtin_echo.c.

Referenced by builtin_echo().

+ Here is the caller graph for this function:

◆ builtin_echo()

int builtin_echo ( char **  args)

Implement the echo command.

This command prints arguments separated by spaces and supports:

  • the -n flag and variants like -nnn
  • multiple consecutive -n flags (consumed before print)
Parameters
argsNULL terminated arg array with arg[0] = "echo"
Returns
always 0

Definition at line 52 of file builtin_echo.c.

References is_n_flag().

Referenced by exec_builtin().

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

Go to the source code of this file.