Handle empty default value during variable expansion (#1)

* Handle empty default value during variable expansion

* Make expression after colon optional

As suggested by @maxbrunsfeld
This commit is contained in:
Mads Hartmann 2018-02-24 22:40:43 +01:00 committed by Max Brunsfeld
parent bda693990e
commit 741cfce4b4
4 changed files with 10016 additions and 9591 deletions

View File

@ -28,12 +28,17 @@ Variable expansions
echo ${abc}
echo ${abc:-def}
echo ${abc:- }
echo ${abc:
}
---
(program
(command (command_name (word)) (expansion (variable_name)))
(command (command_name (word)) (expansion (variable_name) (word))))
(command (command_name (word)) (expansion (variable_name) (word)))
(command (command_name (word)) (expansion (variable_name)))
(command (command_name (word)) (expansion (variable_name))))
===================================
Other variable expansion operators

View File

@ -295,7 +295,7 @@ module.exports = grammar({
seq(
$._variable_name,
choice(':', ':?', '=', ':-', '%', '/'),
$._expression
optional($._expression)
)
),
'}'

8
src/grammar.json vendored
View File

@ -1083,9 +1083,17 @@
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression"
},
{
"type": "BLANK"
}
]
}
]
}

19586
src/parser.c vendored

File diff suppressed because it is too large Load Diff