Livl Shell  0.1
Livl Shell is an intermediate reimplementation of the bash shell in C language.
Functions
builtin_commands.h File Reference

File containing the built-in commands functions to manage the built-in commands such as cd, pwd, echo, exit. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "typedef.h"
#include "constants.h"
#include "command_sequence.h"
#include "alias.h"
Include dependency graph for builtin_commands.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int execute_builtin_command (const Command *command, CommandSequence *sequence)
 Executes a command. More...
 
void pwd ()
 Prints the current working directory.
 
void cd (const char *path)
 Changes the current directory. More...
 
int is_builtin_command (const Command *command, const char *expected)
 Checks if the command is a built-in command. More...
 
int exit_shell (CommandSequence *sequence, int exit_code)
 Exits the shell. More...
 
void echo (const Command *command)
 Prints a message. More...
 

Detailed Description

File containing the built-in commands functions to manage the built-in commands such as cd, pwd, echo, exit.

Author
Julien & Franck
Date
24 Dec 2023

Function Documentation

◆ cd()

void cd ( const char *  path)

Changes the current directory.

Parameters
pathThe path to the new directory

◆ echo()

void echo ( const Command command)

Prints a message.

Parameters
commandThe command to execute to be able to print all the arguments

◆ execute_builtin_command()

int execute_builtin_command ( const Command command,
CommandSequence sequence 
)

Executes a command.

Parameters
commandThe command to execute
sequenceThe command sequence to free
Returns
The status of the execution (0 if success, -1 if not a built-in command, 1 if error)

◆ exit_shell()

int exit_shell ( CommandSequence sequence,
int  exit_code 
)

Exits the shell.

Parameters
sequenceThe command sequence to free
exit_codeThe exit code status

◆ is_builtin_command()

int is_builtin_command ( const Command command,
const char *  expected 
)

Checks if the command is a built-in command.

Parameters
commandThe command to check
expectedThe expected command name
Returns
1 if the command is a built-in command, 0 if not