maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
env.c File Reference
#include "shell.h"
#include "env.h"
#include "libft.h"
#include <stdlib.h>
#include <stdio.h>
#include "exit_status.h"
Include dependency graph for env.c:

Go to the source code of this file.

Functions

void print_env_stack (t_env *envp)
 
int builtin_env (t_ms_data *data)
 

Function Documentation

◆ builtin_env()

int builtin_env ( t_ms_data data)

Definition at line 35 of file env.c.

36{
37 if (ft_strcmp(data->args[0], "env") == 0 && data->args[1] == NULL)
38 print_env_stack(data->envp);
39 else
40 {
41 ft_putstr_fd("env: '", STDERR_FILENO);
42 ft_putstr_fd(data->args[1], STDERR_FILENO);
43 ft_putstr_fd("': No such file or directory\n", STDERR_FILENO);
46 return (IS_DIRECTORY);
47 }
48 return (EXIT_SUCCESS);
49}
void print_env_stack(t_env *envp)
Definition env.c:23
void set_shell_var(t_env **shell_var, const char *key, const char *value)
#define EXIT_SUCCESS
Definition exit_status.h:16
void set_exit_status(int *exit_status, int status_code)
Definition exit_status.c:78
#define IS_DIRECTORY
Definition exit_status.h:20
int ft_strcmp(const char *s1, const char *s2)
Definition ft_strcmp.c:24
char * ft_itoa(int n)
Definition ft_itoa.c:40
void ft_putstr_fd(char *s, int fd)
int exit_status
Definition shell.h:30
t_env * envp
Definition shell.h:24
t_env * shell_variables
Definition shell.h:25
char ** args
Definition shell.h:23

References s_ms_data::args, s_ms_data::envp, s_ms_data::exit_status, EXIT_SUCCESS, ft_itoa(), ft_putstr_fd(), ft_strcmp(), IS_DIRECTORY, print_env_stack(), set_exit_status(), set_shell_var(), and s_ms_data::shell_variables.

Referenced by execute().

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

◆ print_env_stack()

void print_env_stack ( t_env envp)

Definition at line 23 of file env.c.

24{
25 t_env *curr_node;
26
27 curr_node = envp;
28 while (curr_node)
29 {
30 ft_printf("%s=%s\n", curr_node->key, curr_node->value);
31 curr_node = curr_node->next;
32 }
33}
int ft_printf(const char *format,...)
Definition ft_printf.c:37
Definition env.h:17
struct s_env * next
Definition env.h:20
char * key
Definition env.h:18
char * value
Definition env.h:19

References ft_printf(), s_env::key, s_env::next, and s_env::value.

Referenced by builtin_env().

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