[PATCH 2/3] Allow evaluation of arbitrarily-positioned arguments in GRUB2 parser
Samuel Mendoza-Jonas
sam at mendozajonas.com
Tue Apr 26 13:04:59 AEST 2016
Thanks! Merged as 013bf20.
On Wed, Mar 02, 2016 at 08:59:03AM -0800, Alan Dunn wrote:
> GRUB2 allows essentially arbitrary numbers of positional arguments, so
> ensure that they can be evaluated within scripts. GRUB2 also appears
> to support arbitrary numbers of leading 0's in positional parameters
> (i.e., $01 should evalute the same as $1), but this doesn't seem like
> a particularly important case to support.
>
> Tested:
> Modified test-grub2-pos-param to cover higher-numbered positional
> arguments.
>
> Signed-off-by: Alan Dunn <amdunn at google.com>
> ---
> discover/grub2/grub2-lexer.l | 3 ++-
> test/parser/test-grub2-pos-param.c | 6 +++---
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/discover/grub2/grub2-lexer.l b/discover/grub2/grub2-lexer.l
> index 81dc5fe..b55a715 100644
> --- a/discover/grub2/grub2-lexer.l
> +++ b/discover/grub2/grub2-lexer.l
> @@ -24,7 +24,8 @@ void yyerror(struct grub2_parser *parser, const char *fmt, ...);
> WORD [^{}|&$;<> \t\n'"#]+
> DELIM [ \t]+
> BLANK ["]{2}|[']{2}
> -VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#])
> +NUMBER 0|[1-9][0-9]*
> +VARNAME ([[:alpha:]][_[:alnum:]]*|{NUMBER}|[\?@\*#])
>
> %%
>
> diff --git a/test/parser/test-grub2-pos-param.c b/test/parser/test-grub2-pos-param.c
> index 09ac8fc..36447ff 100644
> --- a/test/parser/test-grub2-pos-param.c
> +++ b/test/parser/test-grub2-pos-param.c
> @@ -4,10 +4,10 @@
> #if 0 /* PARSER_EMBEDDED_CONFIG */
>
> function set_params_var {
> - params="$1 $2"
> + params="$1 $2 $10"
> }
> menuentry 'Linux' {
> - set_params_var abc 123
> + set_params_var abc 123 3 4 5 6 7 8 9 bingo
> linux test_kernel $params
> }
>
> @@ -31,5 +31,5 @@ void run_test(struct parser_test *test)
> /* The linux command, $params is expected to have been set when
> * set_params was called in menuentry.
> */
> - check_args(opt, "abc 123");
> + check_args(opt, "abc 123 bingo");
> }
> --
> 2.7.0.rc3.207.g0ac5344
>
> _______________________________________________
> Petitboot mailing list
> Petitboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/petitboot
More information about the Petitboot
mailing list