Commit 2a13d8e2 authored by pêle-mêle's avatar pêle-mêle
Browse files

escape some chars in var values of export output

parent ba1ba449
......@@ -2,14 +2,19 @@
besoin de proteger ft_strcmp? (comments)
export d=\$ vs export d=\1\f ou echo \$
export d='\' f=" la. ok. sf. non"
export f=" la. ok. sf. non"
export
echo $d $f
touch $f
echo $f
echo "$f"
cat $f
cat "$f"
export h=~/fs
export fd='$fs'
command loop (semicolon)
quit apres une erreur de parsing? (fonction error())
par exemple export d=\
testlines pour multipipes :
cat | cat | ls
......
......@@ -18,6 +18,17 @@ char **sort_variables(char **env, char **exported)
return (sorted_array);
}
void print_export_var_value(char *value)
{
while (*value != '\0')
{
if (ft_isset(*value, "$\"\\`") == TRUE)
ft_putchar_fd('\\', STDOUT_FILENO);// change fd
ft_putchar_fd(*value, STDOUT_FILENO);// change fd
value++;
}
}
int print_export(char **env, char **exported)
{
char **variables;
......@@ -36,7 +47,7 @@ int print_export(char **env, char **exported)
{
write(STDOUT_FILENO, variables[i], equalsign_pos + 1);// idem
ft_putchar_fd('"', STDOUT_FILENO); // idem
ft_putstr_fd(variables[i] + equalsign_pos + 1, STDOUT_FILENO);// id
print_export_var_value(variables[i] + equalsign_pos + 1);
ft_putchar_fd('"', STDOUT_FILENO); // id
}
else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment