mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
wordsplit flags: also set W_HASDOLLAR if dollar is found in double quotes
Fixes #15
This commit is contained in:
parent
d26d883a91
commit
695596fde2
2 changed files with 16 additions and 3 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 13:20:01 by jguelen #+# #+# */
|
||||
/* Updated: 2025/02/20 14:17:03 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/24 14:51:09 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ bool rule_quote(t_token_build *builder, char *original)
|
|||
*/
|
||||
bool rule_var_substitution(t_token_build *builder, char *original)
|
||||
{
|
||||
if (unquoted(builder) && original[builder->idx] == '$')
|
||||
if (original[builder->idx] == '$' && builder->quote != '\'')
|
||||
{
|
||||
push_char(builder, original[builder->idx]);
|
||||
builder->cur_flags |= W_HASDOLLAR;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:17:56 by khais #+# #+# */
|
||||
/* Updated: 2025/02/20 14:22:06 by khais ### ########.fr */
|
||||
/* Updated: 2025/02/24 14:49:09 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -187,6 +187,18 @@ static void test_wordsplit_var_substitution(void)
|
|||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
static void test_wordsplit_var_substitution_quotes(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
||||
words = minishell_wordsplit("VAR=\"$VAR\"");
|
||||
assert(W_HASDOLLAR & wordlist_get(words, 0)->flags);
|
||||
wordlist_destroy(words);
|
||||
words = minishell_wordsplit("VAR='$VAR'");
|
||||
assert((W_HASDOLLAR & wordlist_get(words, 0)->flags) == 0);
|
||||
wordlist_destroy(words);
|
||||
}
|
||||
|
||||
static void test_wordsplit_quote_detection_nonnested(void)
|
||||
{
|
||||
t_wordlist *words;
|
||||
|
|
@ -254,6 +266,7 @@ int main(void) {
|
|||
test_wordsplit_all_operators();
|
||||
test_wordsplit_operator_combining();
|
||||
test_wordsplit_var_substitution();
|
||||
test_wordsplit_var_substitution_quotes();
|
||||
test_wordsplit_quote_detection_nonnested();
|
||||
test_wordsplit_quote_detection_nested_double_in_simple();
|
||||
test_wordsplit_quote_detection_nested_single_in_double();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue