From d7577b033831ece9adac8b691b7c412c2407d09d Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sat, 24 Oct 2020 18:36:51 +0330 Subject: [PATCH] Base: Document the new brace expansions in Shell's manpage --- Base/usr/share/man/man5/Shell.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Base/usr/share/man/man5/Shell.md b/Base/usr/share/man/man5/Shell.md index 0acc3019e3..1c81f54fb5 100644 --- a/Base/usr/share/man/man5/Shell.md +++ b/Base/usr/share/man/man5/Shell.md @@ -108,10 +108,19 @@ The shell performs various expansions, in different stages. * Variable Expansion: Variables shall be expanded preserving their types. +* Brace Expansions: Brace expansions shall be expanded to a list. + * Juxtaposition Expansion: Juxtapositions shall be expanded as list products. * Other expansions: Tildes, Evaluate expressions, etc. shall be expanded as needed. +### Brace Expansions +Brace expansions are of two kinds, _normal brace expansions_ and _range brace expansions_. +_Normal brace expansions_ are sequences of optional expressions inside braces (`{}`), delimited by a comma (`','`); a missing expression is treated as an empty string literal. Such expressions are simply expanded to the expressions they enclose. +_Range brace expansions_ are of the form `{start_expression..end_expression}`, where `start_expression` and `end_expression` denote the bounds of an inclusive _range_, and can be one of two types: +- Single unicode code points: The range expands to all code points between the start and end, e.g. `{a..c}` shall expand to the list `(a b c)`. +- Numbers: The range expands to all numbers between the start and end, e.g. `{8..11}` shall expand to the list `(8 9 10 11)`. + ### Juxtapositions Any two expressions joined without any operator are considered to be in a Juxtaposition, with the resulting value being the list product of two expressions. For instance, `(1 2)(3 4)` shall be evaluated to `(13 14 23 24)` by calculating the list product of the two expressions `(1 2)` and `(3 4)`. @@ -341,6 +350,7 @@ string_composite :: string string_composite? | variable string_composite? | bareword string_composite? | glob string_composite? + | brace string_composite? string :: '"' dquoted_string_inner '"' | "'" [^']* "'" @@ -368,6 +378,11 @@ bareword_with_tilde_expansion :: '~' bareword? glob :: [*?] bareword? | bareword [*?] +brace_expansion :: '{' brace_expansion_spec '}' + +brace_expansion_spec :: expression? (',' expression?)* + | expression '..' expression + digit :: number :: identifier ::