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

Builtin function for exporting environment variables. More...

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

Functions

int export_no_args (t_shell *shell)
 Handles the "export" command without arguments.
 
void exporting (t_shell *shell, char *str)
 Updates or creates environment variables based on user-provided arguments.
 
int export_args (t_shell *shell, char **args)
 Handles the export command with specified arguments.
 
int export (t_shell *shell, char **args)
 Implements the export builtin function.
 

Detailed Description

Builtin function for exporting environment variables.

Function Documentation

◆ export()

int export ( t_shell shell,
char **  args 
)

Implements the export builtin function.

This function is responsible for executing the export command. It handles cases where the command is executed with or without arguments and calls the appropriate functions to set or display environment variables. When executed with arguments, it processes each argument and sets or modifies the corresponding environment variable. If executed without arguments, it displays the names and values of all currently set environment variables in the "declare -x KEY=VALUE" format.

Parameters
[in]shellA pointer to the shell struct.
[in]argsAn array of strings containing the arguments.
Returns
An exit status (EXIT_SUCCESS on success, or an error code on failure).

◆ export_args()

int export_args ( t_shell shell,
char **  args 
)

Handles the export command with specified arguments.

This function is called when the export command is executed with one or more arguments. It processes the arguments and sets or modifies environment variables accordingly.

Parameters
[in]shellA pointer to the shell struct.
[in]argsAn array of strings containing the arguments.
Returns
An exit status (EXIT_SUCCESS on success, or an error code on failure).

◆ export_no_args()

int export_no_args ( t_shell shell)

Handles the "export" command without arguments.

This function is called when the export command is executed without any arguments. It displays the names and values of all currently set environment variables in the "declare -x KEY=VALUE" format.

Parameters
[in]shellA pointer to the shell struct.
Returns
An exit status (EXIT_SUCCESS on success, or an error code on failure).

◆ exporting()

void exporting ( t_shell shell,
char *  str 
)

Updates or creates environment variables based on user-provided arguments.

This function processes individual argument strings and sets or modifies environment variables accordingly. It checks for the validity of identifiers and updates their values.

Parameters
[in]shellA pointer to the shell struct.
[in]strThe argument string to be processed and used as an environment variable.