aboutsummaryrefslogtreecommitdiff
path: root/src/builtin/export.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-28 17:53:11 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-28 17:53:11 +0200
commit1f947c5dfe27a9f7ef5734d4ab16a01317e50fe1 (patch)
tree7c5b292b03e6b61102d86fd62ced9aa2a72a3d8c /src/builtin/export.c
parentb1cea511d13775425ee38e70c43e8a81f96b888e (diff)
downloadminishell-1f947c5dfe27a9f7ef5734d4ab16a01317e50fe1.tar.gz
minishell-1f947c5dfe27a9f7ef5734d4ab16a01317e50fe1.tar.bz2
minishell-1f947c5dfe27a9f7ef5734d4ab16a01317e50fe1.zip
Fixing double free redir, export and preprocess on empty value
Diffstat (limited to 'src/builtin/export.c')
-rw-r--r--src/builtin/export.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/builtin/export.c b/src/builtin/export.c
index 6fbb88f..e19756d 100644
--- a/src/builtin/export.c
+++ b/src/builtin/export.c
@@ -6,7 +6,7 @@
/* By: charles <charles@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:11:34 by charles #+# #+# */
-/* Updated: 2020/07/19 18:46:48 by charles ### ########.fr */
+/* Updated: 2020/08/28 17:49:47 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -40,7 +40,6 @@ int builtin_export(char **argv, t_env env)
int status;
size_t i;
char *equal_ptr;
- bool skip;
if (argv[1] == NULL)
{
@@ -51,20 +50,18 @@ int builtin_export(char **argv, t_env env)
i = 0;
while (argv[++i] != NULL)
{
- skip = (equal_ptr = ft_strchr(argv[i], '=')) == NULL;
- if (!skip)
+ equal_ptr = ft_strchr(argv[i], '=');
+ if (equal_ptr != NULL)
*equal_ptr = '\0';
if (!utils_valid_identifier(argv[i]))
{
- if (!skip)
+ if (equal_ptr != NULL)
*equal_ptr = '=';
errorf("export: `%s': not a valid identifier\n", argv[i]);
status = 1;
continue;
}
- if (skip)
- continue;
- if (env_export(env, argv[i], equal_ptr + 1) == NULL)
+ if (env_export(env, argv[i], equal_ptr == NULL ? "" : equal_ptr + 1) == NULL)
return (127); // malloc error
}
return (status);