diff --git a/builder/dockerfile/shell/envVarTest b/builder/dockerfile/shell/envVarTest index 6071caebd2..08011801c5 100644 --- a/builder/dockerfile/shell/envVarTest +++ b/builder/dockerfile/shell/envVarTest @@ -174,6 +174,22 @@ A|$9 | A|${9} | A|${9:+bbb} | A|${9:-bbb} | bbb +A|$999 | +A|${999} | +A|${999:+bbb} | +A|${999:-bbb} | bbb +A|$999aaa | aaa +A|${999}aaa | aaa +A|${999:+bbb}aaa | aaa +A|${999:-bbb}aaa | bbbaaa +A|$001 | +A|${001} | +A|${001:+bbb} | +A|${001:-bbb} | bbb +A|$001aaa | aaa +A|${001}aaa | aaa +A|${001:+bbb}aaa | aaa +A|${001:-bbb}aaa | bbbaaa # Special parameters won't be set in the Dockerfile: # http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_05_02 @@ -181,6 +197,11 @@ A|$@ | A|${@} | A|${@:+bbb} | A|${@:-bbb} | bbb +A|$@@@ | @@ +A|$@aaa | aaa +A|${@}aaa | aaa +A|${@:+bbb}aaa | aaa +A|${@:-bbb}aaa | bbbaaa A|$* | A|${*} | A|${*:+bbb} | diff --git a/builder/dockerfile/shell/lex.go b/builder/dockerfile/shell/lex.go index a51a2665aa..0c80900ade 100644 --- a/builder/dockerfile/shell/lex.go +++ b/builder/dockerfile/shell/lex.go @@ -318,7 +318,15 @@ func (sw *shellWord) processName() string { for sw.scanner.Peek() != scanner.EOF { ch := sw.scanner.Peek() - if name.Len() == 0 && (unicode.IsDigit(ch) || isSpecialParam(ch)) { + if name.Len() == 0 && unicode.IsDigit(ch) { + for sw.scanner.Peek() != scanner.EOF && unicode.IsDigit(sw.scanner.Peek()) { + // Keep reading until the first non-digit character, or EOF + ch = sw.scanner.Next() + name.WriteRune(ch) + } + return name.String() + } + if name.Len() == 0 && isSpecialParam(ch) { ch = sw.scanner.Next() return string(ch) }