diff --git a/src/executing/simple_cmd/builtin_export.c b/src/executing/simple_cmd/builtin_export.c index 64260cf..131100f 100644 --- a/src/executing/simple_cmd/builtin_export.c +++ b/src/executing/simple_cmd/builtin_export.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/01 14:00:32 by khais #+# #+# */ -/* Updated: 2025/04/01 15:58:28 by khais ### ########.fr */ +/* Updated: 2025/04/18 10:01:59 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,19 +18,26 @@ #include #include "../../parser/matchers/identifier.h" +static void invalid_ident(char *ident) +{ + ft_dprintf(STDERR_FILENO, + "minishell: export: `%s': not a valid identifier\n", ident); +} + static void single_export(char *arg, t_minishell *app) { char *key; char *value; + if (arg[0] == '\0') + invalid_ident(arg); if (ft_strchr(arg, '=') != NULL) { key = envp_get_key(arg); value = envp_get_val(arg); if (is_identifier(key) == false) { - ft_dprintf(STDERR_FILENO, - "minishell: export: `%s': not a valid identifier\n", arg); + invalid_ident(arg); free2(key, value); app->last_return_value = 1; } diff --git a/test.sh b/test.sh index d2e18ad..dca722c 100755 --- a/test.sh +++ b/test.sh @@ -747,4 +747,12 @@ expecting <