mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
wordsplit: return error for unclosed quotes
This commit is contained in:
parent
7806043a98
commit
558ddb4096
2 changed files with 23 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 17:02:32 by khais #+# #+# */
|
||||
/* Updated: 2025/02/17 14:20:45 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/17 14:54:11 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -106,5 +106,7 @@ t_wordlist *minishell_wordsplit(char *original)
|
|||
break ;
|
||||
idx++;
|
||||
}
|
||||
if (quote != '\0')
|
||||
return (wordlist_destroy(wordlist), NULL);
|
||||
return (wordlist);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
||||
/* Updated: 2025/02/17 14:37:17 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/17 14:55:31 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "testutil.h"
|
||||
#include "libft.h"
|
||||
#include "../src/parser/wordsplit/wordsplit.h"
|
||||
#include "unistd.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
|
|
@ -112,6 +113,22 @@ static void test_wordsplit_mixed_broken(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
static void test_wordsplit_unclosed_single(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("'hello");
|
||||
assert(words == NULL);
|
||||
}
|
||||
|
||||
static void test_wordsplit_unclosed_double(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("\"hello");
|
||||
assert(words == NULL);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test_wordsplit_singleword();
|
||||
test_wordsplit_singleword_with_blanks();
|
||||
|
|
@ -121,5 +138,7 @@ int main(void) {
|
|||
test_wordsplit_mixed_single_in_double();
|
||||
test_wordsplit_mixed_double_in_single();
|
||||
test_wordsplit_mixed_broken();
|
||||
test_wordsplit_unclosed_single();
|
||||
test_wordsplit_unclosed_double();
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue