mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(builtin/export): show error on invalid identifiers such as % and $
This commit is contained in:
parent
efaf4708f9
commit
c5e15903e0
2 changed files with 27 additions and 9 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/01 14:00:32 by khais #+# #+# */
|
||||
/* Updated: 2025/04/18 10:01:59 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/18 10:09:09 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,21 +29,24 @@ 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);
|
||||
if (is_identifier(key))
|
||||
{
|
||||
key = envp_get_key(arg);
|
||||
value = envp_get_val(arg);
|
||||
if (is_identifier(key) == false)
|
||||
if (value[0] == '\0' && ft_strchr(arg, '=') == NULL)
|
||||
{
|
||||
invalid_ident(arg);
|
||||
free2(key, value);
|
||||
app->last_return_value = 1;
|
||||
return ;
|
||||
}
|
||||
else if (env_set_entry(&app->env, key, value) == NULL)
|
||||
if (env_set_entry(&app->env, key, value) == NULL)
|
||||
ft_perror("minishell: export");
|
||||
}
|
||||
else
|
||||
{
|
||||
free(key);
|
||||
invalid_ident(arg);
|
||||
app->last_return_value = 1;
|
||||
}
|
||||
}
|
||||
|
||||
t_builtin_type builtin_export(t_simple_cmd *cmd, t_minishell *app)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue