Allow $ at the end of a bare word

Fixes #38
This commit is contained in:
Max Brunsfeld 2018-11-04 15:33:45 -08:00
parent 47f3e5208b
commit 25f56dd856
5 changed files with 107429 additions and 102544 deletions

View File

@ -157,6 +157,18 @@ cat ${BAR} ${ABC=def} ${GHI:?jkl}
(string (simple_expansion (variable_name))) (string (simple_expansion (variable_name)))
(string (expansion (variable_name) (concatenation (word))))))) (string (expansion (variable_name) (concatenation (word)))))))
=============================
Words ending with '$'
=============================
grep ^${var}$
---
(program (command
(command_name (word))
(concatenation (word) (expansion (variable_name)))))
============================= =============================
Command substitutions Command substitutions
============================= =============================

View File

@ -252,6 +252,11 @@ Test commands with regexes
[[ $CMD =~ (^|;)update_terminal_cwd($|;) ]] [[ $CMD =~ (^|;)update_terminal_cwd($|;) ]]
[[ ! " ${completions[*]} " =~ " $alias_cmd " ]] [[ ! " ${completions[*]} " =~ " $alias_cmd " ]]
! [[ "$a" =~ ^a|b\ *c|d$ ]] ! [[ "$a" =~ ^a|b\ *c|d$ ]]
[[ "$1" =~ ^${var}${var}*=..* ]]
[[ "$1" =~ ^\-${var}+ ]]
[[ ${var1} == *${var2}* ]]
[[ "$server" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]
[[ "$primary_wins" =~ ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) ]]
--- ---
@ -273,7 +278,27 @@ Test commands with regexes
(test_command (test_command
(binary_expression (binary_expression
(string (simple_expansion (variable_name))) (string (simple_expansion (variable_name)))
(regex))))) (regex))))
(test_command
(binary_expression
(string (simple_expansion (variable_name)))
(regex)))
(test_command
(binary_expression
(string (simple_expansion (variable_name)))
(regex)))
(test_command
(binary_expression
(expansion (variable_name))
(regex)))
(test_command
(binary_expression
(string (simple_expansion (variable_name)))
(regex)))
(test_command
(binary_expression
(string (simple_expansion (variable_name)))
(regex))))
=============================== ===============================
Subshells Subshells

View File

@ -404,6 +404,7 @@ module.exports = grammar({
$._special_character, $._special_character,
) )
))), ))),
optional(seq($._concat, '$'))
)), )),
_special_character: $ => token(prec(-1, choice('{', '}', '[', ']'))), _special_character: $ => token(prec(-1, choice('{', '}', '[', ']'))),

21
src/grammar.json vendored
View File

@ -1615,6 +1615,27 @@
] ]
} }
} }
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_concat"
},
{
"type": "STRING",
"value": "$"
}
]
},
{
"type": "BLANK"
}
]
} }
] ]
} }

209912
src/parser.c vendored

File diff suppressed because it is too large Load Diff