mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
quote marking: ensure that $ detection does not interfere
This commit is contained in:
parent
33fc88eeed
commit
f60e922680
1 changed files with 10 additions and 3 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/06 15:53:03 by khais ### ########.fr */
|
/* Updated: 2025/03/06 16:42:12 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -221,18 +221,19 @@ static void test_wordsplit_operator_combining(void)
|
||||||
wordlist_destroy(words);
|
wordlist_destroy(words);
|
||||||
}
|
}
|
||||||
|
|
||||||
// kco work marker
|
|
||||||
|
|
||||||
static void test_wordsplit_var_substitution(void)
|
static void test_wordsplit_var_substitution(void)
|
||||||
{
|
{
|
||||||
t_wordlist *words;
|
t_wordlist *words;
|
||||||
|
|
||||||
words = minishell_wordsplit("echo VAR=$VAR here");
|
words = minishell_wordsplit("echo VAR=$VAR here");
|
||||||
assert_strequal("echo", wordlist_get(words, 0)->word);
|
assert_strequal("echo", wordlist_get(words, 0)->word);
|
||||||
|
assert_strequal(" ", wordlist_get(words, 0)->marker);
|
||||||
assert(0 == wordlist_get(words, 0)->flags);
|
assert(0 == wordlist_get(words, 0)->flags);
|
||||||
assert_strequal("VAR=$VAR", wordlist_get(words, 1)->word);
|
assert_strequal("VAR=$VAR", wordlist_get(words, 1)->word);
|
||||||
|
assert_strequal(" ", wordlist_get(words, 1)->marker);
|
||||||
assert(W_HASDOLLAR == wordlist_get(words, 1)->flags);
|
assert(W_HASDOLLAR == wordlist_get(words, 1)->flags);
|
||||||
assert_strequal("here", wordlist_get(words, 2)->word);
|
assert_strequal("here", wordlist_get(words, 2)->word);
|
||||||
|
assert_strequal(" ", wordlist_get(words, 2)->marker);
|
||||||
assert(0 == wordlist_get(words, 2)->flags);
|
assert(0 == wordlist_get(words, 2)->flags);
|
||||||
wordlist_destroy(words);
|
wordlist_destroy(words);
|
||||||
}
|
}
|
||||||
|
|
@ -242,13 +243,19 @@ static void test_wordsplit_var_substitution_quotes(void)
|
||||||
t_wordlist *words;
|
t_wordlist *words;
|
||||||
|
|
||||||
words = minishell_wordsplit("VAR=\"$VAR\"");
|
words = minishell_wordsplit("VAR=\"$VAR\"");
|
||||||
|
assert_strequal("VAR=\"$VAR\"", wordlist_get(words, 0)->word);
|
||||||
|
assert_strequal(" \"\"\"\" ", wordlist_get(words, 0)->marker);
|
||||||
assert(W_HASDOLLAR & wordlist_get(words, 0)->flags);
|
assert(W_HASDOLLAR & wordlist_get(words, 0)->flags);
|
||||||
wordlist_destroy(words);
|
wordlist_destroy(words);
|
||||||
words = minishell_wordsplit("VAR='$VAR'");
|
words = minishell_wordsplit("VAR='$VAR'");
|
||||||
|
assert_strequal("VAR='$VAR'", wordlist_get(words, 0)->word);
|
||||||
assert((W_HASDOLLAR & wordlist_get(words, 0)->flags) == 0);
|
assert((W_HASDOLLAR & wordlist_get(words, 0)->flags) == 0);
|
||||||
|
assert_strequal(" '''' ", wordlist_get(words, 0)->marker);
|
||||||
wordlist_destroy(words);
|
wordlist_destroy(words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// kco work marker
|
||||||
|
|
||||||
static void test_wordsplit_quote_detection_nonnested(void)
|
static void test_wordsplit_quote_detection_nonnested(void)
|
||||||
{
|
{
|
||||||
t_wordlist *words;
|
t_wordlist *words;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue