mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
env: correctly handle write errors such as /dev/full
The exit status of 125 for env in case of failure is documented in env(1).
This commit is contained in:
parent
ffaf2582a3
commit
0579d1f2fc
1 changed files with 11 additions and 2 deletions
|
|
@ -6,12 +6,20 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/02 19:35:52 by khais #+# #+# */
|
/* Created: 2025/04/02 19:35:52 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/02 19:38:16 by khais ### ########.fr */
|
/* Updated: 2025/04/14 11:58:15 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static t_builtin_type write_error(t_minishell *app)
|
||||||
|
{
|
||||||
|
app->last_return_value = 125;
|
||||||
|
perror("minishell: env: write error");
|
||||||
|
return (BUILTIN_ENV);
|
||||||
|
}
|
||||||
|
|
||||||
t_builtin_type builtin_env(t_simple_cmd *cmd, t_minishell *app)
|
t_builtin_type builtin_env(t_simple_cmd *cmd, t_minishell *app)
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +30,8 @@ t_builtin_type builtin_env(t_simple_cmd *cmd, t_minishell *app)
|
||||||
env = app->env;
|
env = app->env;
|
||||||
while (env != NULL)
|
while (env != NULL)
|
||||||
{
|
{
|
||||||
ft_printf("%s=%s\n", env->key, env->value);
|
if (ft_printf("%s=%s\n", env->key, env->value) < 0)
|
||||||
|
return (write_error(app));
|
||||||
env = env->next;
|
env = env->next;
|
||||||
}
|
}
|
||||||
app->last_return_value = 0;
|
app->last_return_value = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue