]> git.ozlabs.org Git - petitboot/commitdiff
discover/grub2: Do not set $0 in functions
authorAlan Dunn <amdunn@google.com>
Wed, 2 Mar 2016 16:59:04 +0000 (08:59 -0800)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 26 Apr 2016 02:57:16 +0000 (12:57 +1000)
GRUB2 does not set $0 in functions, so don't set it in our GRUB2
script parser.  (As it doesn't have a value in GRUB2 scripts, probably
no GRUB2 script depends on the value of $0.)  Additionally, dash and
bash set environment variable 0 to the name of the script (even in
functions), so the current behavior of $0 doesn't really match shell
scripts either.

Tested:
 Existing tests pass.

Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/grub2/script.c

index 48c963e7549c1982d45d1143895be4f301132e55..ed81a202c01fd068717081f1e3de10d91540d976 100644 (file)
@@ -379,7 +379,7 @@ static int function_invoke(struct grub2_script *script,
        int i;
 
        /* set positional parameters */
-       for (i = 0; i < argc; i++) {
+       for (i = 1; i < argc; i++) {
                name = talloc_asprintf(script, "%d", i);
                script_env_set(script, name, argv[i]);
        }