minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
handle_single_builtin.c File Reference

Single builtin-command Execution Functions. More...

#include "minishell.h"
Include dependency graph for handle_single_builtin.c:

Functions

bool is_builtin (char *exec)
 Check if a given command is a builtin-command.
 
void execute_builtin (t_shell *shell)
 Execute a builtin-command.
 
int handle_single_builtin (t_shell *shell)
 Handle the execution of a single builtin-command.
 

Detailed Description

Single builtin-command Execution Functions.

This file contains functions responsible for executing builtin-commands within the project. It includes functions to identify builtins, execute them, and handle single builtin commands.

Function Documentation

◆ execute_builtin()

void execute_builtin ( t_shell shell)

Execute a builtin-command.

The execute_builtin function executes the appropriate builtin-command based on the provided command name in the execs array. It sets the global g_exit_code variable to the exit status of the command.

Parameters
[in,out]shellA pointer to the shell struct.

◆ handle_single_builtin()

int handle_single_builtin ( t_shell shell)

Handle the execution of a single builtin-command.

The handle_single_builtin function checks if the provided command is a builtin, saves the file descriptors, handles standard input and output redirections, executes the builtin-command and restores standard file descriptors.

Parameters
[in,out]shellA pointer to the shell struct.
Returns
The status code indicating the execution result.

◆ is_builtin()

bool is_builtin ( char *  exec)

Check if a given command is a builtin-command.

This function determines whether the provided command is one of the shell builtin-commands such as "echo", "cd", "pwd", "export", "unset", "env" or "exit."

Parameters
[in]execThe command name to check.
Returns
true if the command is a built-in, false otherwise.