Handle strings containing command substitutions
This commit is contained in:
parent
e9afbb4381
commit
3abfbbd7bd
|
@ -120,3 +120,19 @@ echo "a ${b} c" "d $e"
|
|||
(command (command_name)
|
||||
(string (expansion (variable_name)))
|
||||
(string (simple_expansion (variable_name)))))
|
||||
|
||||
=========================================
|
||||
Strings containing command substitutions
|
||||
=========================================
|
||||
|
||||
find "`dirname $file`" -name "$base"'*'
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(command
|
||||
(command_name)
|
||||
(string (command_substitution (command (command_name) (simple_expansion (variable_name)))))
|
||||
(word)
|
||||
(string (simple_expansion (variable_name)))
|
||||
(raw_string)))
|
||||
|
|
15
grammar.js
15
grammar.js
|
@ -131,7 +131,7 @@ module.exports = grammar({
|
|||
$._statement
|
||||
)),
|
||||
|
||||
list: $ => prec.left(seq(
|
||||
list: $ => prec.left(-1, seq(
|
||||
$._statement,
|
||||
choice('&&', '||'),
|
||||
$._statement
|
||||
|
@ -204,6 +204,7 @@ module.exports = grammar({
|
|||
_expression: $ => choice(
|
||||
$.word,
|
||||
$.string,
|
||||
$.array,
|
||||
$.raw_string,
|
||||
$.expansion,
|
||||
$.simple_expansion,
|
||||
|
@ -214,7 +215,7 @@ module.exports = grammar({
|
|||
string: $ => seq(
|
||||
'"',
|
||||
repeat(choice(
|
||||
/[^"$]+/,
|
||||
/[^"`$]+/,
|
||||
$.expansion,
|
||||
$.simple_expansion,
|
||||
$.command_substitution
|
||||
|
@ -222,6 +223,12 @@ module.exports = grammar({
|
|||
'"'
|
||||
),
|
||||
|
||||
array: $ => seq(
|
||||
'(',
|
||||
repeat($.word),
|
||||
')'
|
||||
),
|
||||
|
||||
raw_string: $ => /'[^']*'/,
|
||||
|
||||
simple_expansion: $ => seq(
|
||||
|
@ -248,8 +255,8 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
command_substitution: $ => choice(
|
||||
seq('$(', $.command, ')'),
|
||||
seq('`', $.command, '`')
|
||||
seq('$(', $._statement, ')'),
|
||||
prec(1, seq('`', $._statement, '`'))
|
||||
),
|
||||
|
||||
process_substitution: $ => seq(
|
||||
|
|
|
@ -396,7 +396,7 @@
|
|||
},
|
||||
"list": {
|
||||
"type": "PREC_LEFT",
|
||||
"value": 0,
|
||||
"value": -1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
@ -727,6 +727,10 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "string"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "array"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "raw_string"
|
||||
|
@ -763,7 +767,7 @@
|
|||
"members": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "[^\"$]+"
|
||||
"value": "[^\"`$]+"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
@ -786,6 +790,26 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"array": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "word"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"raw_string": {
|
||||
"type": "PATTERN",
|
||||
"value": "'[^']*'"
|
||||
|
@ -900,7 +924,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "command"
|
||||
"name": "_statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -909,6 +933,9 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"type": "PREC",
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
|
@ -917,7 +944,7 @@
|
|||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "command"
|
||||
"name": "_statement"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
|
@ -925,6 +952,7 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"process_substitution": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue