wordsplit: handle single quotes

This commit is contained in:
Khaïs COLIN 2025-02-14 17:50:56 +01:00
parent 81d28c15d4
commit 5276aba278
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
2 changed files with 31 additions and 10 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
/* Updated: 2025/02/14 16:16:14 by khais ### ########.fr */
/* Updated: 2025/02/14 17:37:46 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -54,9 +54,21 @@ void test_wordsplit_multiword(void)
wordlist_destroy(words);
}
void test_wordsplit_multiword_with_single_quotes(void)
{
t_wordlist *words;
words = minishell_wordsplit("\t echo\t' \t The file is named $MYFILE ' \t");
assert_strequal("echo", wordlist_get(words, 0)->word);
assert_strequal("' \t The file is named $MYFILE '", wordlist_get(words, 1)->word);
assert(NULL == wordlist_get(words, 2));
wordlist_destroy(words);
}
int main(void) {
test_wordsplit_singleword();
test_wordsplit_singleword_with_blanks();
test_wordsplit_multiword();
test_wordsplit_multiword_with_single_quotes();
return (0);
}