MiniDevil As beautiful as a shell
builtin_env.c
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* builtin_env.c :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: baelgadi <baelgadi@student.42.fr> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2025/12/11 22:53:19 by baelgadi #+# #+# */
9 /* Updated: 2026/03/04 08:51:20 by baelgadi ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #include "builtins.h"
14 #include "libft.h"
15 
26 int builtin_env(char **args, t_env *env)
27 {
28  t_env *current;
29 
30  if (args && args[1])
31  {
32  ft_putstr_fd("minishell: env: too many arguments\n", STDERR_FILENO);
33  return (127);
34  }
35  current = env;
36  while (current)
37  {
38  if (current->value)
39  {
40  ft_putstr_fd(current->key, STDOUT_FILENO);
41  ft_putchar_fd('=', STDOUT_FILENO);
42  ft_putendl_fd(current->value, STDOUT_FILENO);
43  }
44  current = current->next;
45  }
46  return (0);
47 }
int builtin_env(char **args, t_env *env)
Implement the env command.
Definition: builtin_env.c:26
Shell builtin commands prototypes.
Environment variable (doubly linked list)
Definition: structs.h:87
char * key
Variable name.
Definition: structs.h:88
char * value
Value (NULL if export only)
Definition: structs.h:89
struct s_env * next
Next node.
Definition: structs.h:90