49 arr = malloc((count + 1) *
sizeof(
t_env *));
81 while (j < count - 1 - i)
83 if (ft_strncmp(arr[j]->key, arr[j + 1]->key, -1) > 0)
102 ft_putstr_fd(
"declare -x ", STDOUT_FILENO);
103 ft_putstr_fd(var->
key, STDOUT_FILENO);
104 if (var->
value != NULL)
106 ft_putstr_fd(
"=\"", STDOUT_FILENO);
107 ft_putstr_fd(var->
value, STDOUT_FILENO);
108 ft_putchar_fd(
'"', STDOUT_FILENO);
110 ft_putchar_fd(
'\n', STDOUT_FILENO);
Shell builtin commands prototypes.
void print_sorted_export(t_env *env)
Print all env vars sorted in alphabetical order, in declare -x format.
static int count_env(t_env *env)
Count the number of nodes in an env list.
static void print_one_export(t_env *var)
Print a single env var in "declare -x" format.
static t_env ** env_to_node_array(t_env *env, int count)
Convert env linked list to an array of node pointers.
static void sort_env_array(t_env **arr, int count)
Sort an array of env node pointers by key in alphabetical order.
Environment variable (doubly linked list)
char * value
Value (NULL if export only)
struct s_env * next
Next node.