minishell
Minishell Project for École 42
|
Builtin function for exporting environment variables. More...
#include "minishell.h"
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. | |
Builtin function for exporting environment variables.
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.
[in] | shell | A pointer to the shell struct. |
[in] | args | An array of strings containing the arguments. |
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.
[in] | shell | A pointer to the shell struct. |
[in] | args | An array of strings containing the arguments. |
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.
[in] | shell | A pointer to the shell struct. |
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.
[in] | shell | A pointer to the shell struct. |
[in] | str | The argument string to be processed and used as an environment variable. |