Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit
minishell
Commits
2a13d8e2
Commit
2a13d8e2
authored
Jan 04, 2021
by
pêle-mêle
Browse files
escape some chars in var values of export output
parent
ba1ba449
Changes
2
Hide whitespace changes
Inline
Side-by-side
notes.txt
View file @
2a13d8e2
...
...
@@ -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
...
...
src/execution/ft_export.c
View file @
2a13d8e2
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment