Skip to content

Commit e1c75cd

Browse files
committed
[readme] document parse's supported parameter-expansion subset
1 parent c0842c8 commit e1c75cd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ Return an array of arguments from the quoted string `cmd`.
131131
Interpolate embedded bash-style `$VARNAME` and `${VARNAME}` variables with
132132
the `env` object which like bash will replace undefined variables with `""`.
133133

134+
Only simple `$VARNAME` and `${VARNAME}` interpolation is supported.
135+
Bash parameter expansion beyond a plain variable name is not evaluated:
136+
forms such as array subscripts (`${arr[i]}`), length (`${#arr[@]}`),
137+
and modifiers (`${var:-default}`, `${var/a/b}`)
138+
are treated as an unknown variable and expand to `""`,
139+
while arithmetic (`$((...))`) and command substitution (`$(...)`)
140+
are not interpreted.
141+
Whitespace inside `${...}` throws a `Bad substitution` error.
142+
134143
`env` is usually an object but it can also be a function to perform lookups.
135144
When `env(key)` returns a string, its result will be output just like `env[key]`
136145
would. When `env(key)` returns an object, it will be inserted into the result

0 commit comments

Comments
 (0)