Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ENV values to have spaces and be multiline #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions corpus/env.txt
Original file line number Diff line number Diff line change
@@ -122,3 +122,39 @@ ENV TZ America/Toronto
(env_pair
name: (unquoted_string)
value: (unquoted_string))))

================================================================================
Space syntax where value has spaces
================================================================================

ENV BUILD_PACKAGES bash curl

--------------------------------------------------------------------------------

(source_file
(env_instruction
(env_pair
name: (unquoted_string)
value: (unquoted_string
(shell_fragment)))))

================================================================================
Space syntax where value has spaces and multiple lines
================================================================================

ENV BUILD_PACKAGES bash curl \
openssl \
tar xz gcc python

--------------------------------------------------------------------------------

(source_file
(env_instruction
(env_pair
name: (unquoted_string)
value: (unquoted_string
(shell_fragment)
(line_continuation)
(shell_fragment)
(line_continuation)
(shell_fragment)))))
7 changes: 6 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
@@ -224,7 +224,12 @@ module.exports = grammar({
seq(
field("name", $._env_key),
token.immediate(/\s+/),
field("value", choice($.double_quoted_string, $.unquoted_string))
field("value",
choice(
$.double_quoted_string,
$.unquoted_string,
alias($.shell_command, $.unquoted_string)
))
),

_env_key: ($) =>
9 changes: 9 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
@@ -1028,6 +1028,15 @@
{
"type": "SYMBOL",
"name": "unquoted_string"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "shell_command"
},
"named": true,
"value": "unquoted_string"
}
]
}
12 changes: 12 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
@@ -716,9 +716,21 @@
"multiple": true,
"required": false,
"types": [
{
"type": "comment",
"named": true
},
{
"type": "expansion",
"named": true
},
{
"type": "line_continuation",
"named": true
},
{
"type": "shell_fragment",
"named": true
}
]
}
7,229 changes: 3,820 additions & 3,409 deletions src/parser.c

Large diffs are not rendered by default.