mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
export: set correct exit status
This commit is contained in:
parent
3cdf7c3f76
commit
ba4192bf8d
2 changed files with 9 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/01 14:00:32 by khais #+# #+# */
|
||||
/* Updated: 2025/04/01 15:53:06 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/01 15:58:28 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,6 +32,7 @@ static void single_export(char *arg, t_minishell *app)
|
|||
ft_dprintf(STDERR_FILENO,
|
||||
"minishell: export: `%s': not a valid identifier\n", arg);
|
||||
free2(key, value);
|
||||
app->last_return_value = 1;
|
||||
}
|
||||
else if (env_set_entry(&app->env, key, value) == NULL)
|
||||
ft_perror("minishell: export");
|
||||
|
|
@ -45,6 +46,7 @@ t_builtin_type builtin_export(t_simple_cmd *cmd, t_minishell *app)
|
|||
|
||||
i = 1;
|
||||
arg = wordlist_get(cmd->words, i++);
|
||||
app->last_return_value = 0;
|
||||
while (arg != NULL)
|
||||
{
|
||||
single_export(arg->word, app);
|
||||
|
|
|
|||
6
test.sh
6
test.sh
|
|
@ -307,25 +307,31 @@ EXTRAENV=-i
|
|||
when_run <<EOF "export with strange inputs"
|
||||
export PATH=$PATH
|
||||
export var
|
||||
echo status=\$?
|
||||
echo var=[\$var]
|
||||
export blue=
|
||||
echo status=\$?
|
||||
echo blue=[\$blue]
|
||||
env -u PATH env
|
||||
EOF
|
||||
expecting <<EOF
|
||||
status=0
|
||||
var=[]
|
||||
status=0
|
||||
blue=[]
|
||||
blue=
|
||||
EOF
|
||||
|
||||
when_run <<"EOF" "export with invalid identifiers"
|
||||
export = 123=456 hello=hi 456=789
|
||||
echo status=$?
|
||||
echo hello=$hello
|
||||
EOF
|
||||
expecting <<"EOF"
|
||||
minishell: export: `=': not a valid identifier
|
||||
minishell: export: `123=456': not a valid identifier
|
||||
minishell: export: `456=789': not a valid identifier
|
||||
status=1
|
||||
hello=hi
|
||||
EOF
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue