create variables when exporting them
PATCH 1/1 create variables when exporting them
This patch changes grub_env_export to create variables with empty value, if necessary.
This makes it possible to export variables before actually assigning them any value and is the way bash behaves.
Thanks
Andreas
ChangeLog:
2009-10-15 Andreas Born <[email protected]>
* kern/env.c (grub_env_export): Create inexistent variables
before exporting.
env.c +7 -2
@@ -170,8 +171,13 @@struct grub_env_var *var; var =grub_env_find (name); -if (var) - var->type =GRUB_ENV_VAR_GLOBAL ; +if (! var) + { +if (grub_env_set (name,"" ) !=GRUB_ERR_NONE ) +return grub_errno; + var =grub_env_find (name); + } + var->type =GRUB_ENV_VAR_GLOBAL ;return GRUB_ERR_NONE ; }
Quoted 4 lines · Andreas Born
This patch changes
grub_env_exportto create variables with empty value, if necessary.
This makes it possible to export variables before actually assigning them any value and is the way bash behaves.
This makes sense to me (although bash is "too big and too slow" and we'll never implement anything close to all of it, this is a pretty cheap way to reduce confusion due to differences), although probably for post-1.97. A couple of nits:
Quoted 2 lines
*
kern/env.c(grub_env_export): Create inexistent variables
before exporting.
"nonexistent"
env.c line 179
Quoted 6 lines
env.c +6
-0+if (! var) + { +if (grub_env_set (name,"" ) !=GRUB_ERR_NONE ) +return grub_errno; + var =grub_env_find (name); + }
GNU brace style involves indenting the braces as well, thus:
if (! var)
{
if (grub_env_set (name, "") != GRUB_ERR_NONE)
return grub_errno;
var = grub_env_find (name);
} Signature · 1 line
Colin Watson [[email protected]]
Here you go:
ChangeLog:
2009-10-15 Andreas Born <[email protected]>
* kern/env.c (grub_env_export): Create nonexistent variables
before exporting.
The mixed indentation (tabs and spaces) in kern/env.c was a bit confusing.
Andreas
Quoted 27 lines · Colin Watson
Quoted 3 lines · Andreas Born
This patch changes
grub_env_exportto create variables with empty value, if necessary.
This makes it possible to export variables before actually assigning them any value and is the way bash behaves.This makes sense to me (although bash is "too big and too slow" and we'll never implement anything close to all of it, this is a pretty cheap way to reduce confusion due to differences), although probably for post-1.97. A couple of nits:
Quoted 3 lines
*
kern/env.c(grub_env_export): Create inexistent variables
before exporting."nonexistent"
Review
Quoted 7 lines
(quoted diff) +6
-0+ if (! var) + { + if (grub_env_set (name, "") != GRUB_ERR_NONE) + return grub_errno; + var = grub_env_find (name); + }
Quoted 10 lines
GNU brace style involves indenting the braces as well, thus:
if (! var) { if (grub_env_set (name, "") != GRUB_ERR_NONE) return grub_errno; var = grub_env_find (name); }
env.c +7 -2
@@ -170,8 +171,13 @@struct grub_env_var *var; var =grub_env_find (name); -if (var) - var->type =GRUB_ENV_VAR_GLOBAL ; +if (! var) + { +if (grub_env_set (name,"" ) !=GRUB_ERR_NONE ) +return grub_errno; + var =grub_env_find (name); + } + var->type =GRUB_ENV_VAR_GLOBAL ;return GRUB_ERR_NONE ; }
Same here. Nothing changed as of r1917 and I didn't get any further feedback either. I've attached a rediffed version, too.
Quoted 8 lines · Andreas Born
Here you go:
ChangeLog:
2009-10-15 Andreas Born <[email protected]>*
kern/env.c(grub_env_export): Create nonexistent variables
before exporting.
Quoted 41 lines
The mixed indentation (tabs and spaces) in
kern/env.cwas a bit confusing.Andreas
Quoted 35 lines · Colin Watson
Quoted 3 lines · Andreas Born
This patch changes
grub_env_exportto create variables with empty value, if necessary.
This makes it possible to export variables before actually assigning them any value and is the way bash behaves.This makes sense to me (although bash is "too big and too slow" and we'll never implement anything close to all of it, this is a pretty cheap way to reduce confusion due to differences), although probably for post-1.97. A couple of nits:
Quoted 3 lines
*
kern/env.c(grub_env_export): Create inexistent variables
before exporting."nonexistent"
env.c line 179
Quoted 6 lines
env.c +6
-0+if (! var) + { +if (grub_env_set (name,"" ) !=GRUB_ERR_NONE ) +return grub_errno; + var =grub_env_find (name); + }GNU brace style involves indenting the braces as well, thus:
if (! var) { if (grub_env_set (name, "") != GRUB_ERR_NONE) return grub_errno; var = grub_env_find (name); }
@@ -170,8 +171,13 @@
struct grub_env_var *var;
var = grub_env_find (name);
- if (var)
- var->type = GRUB_ENV_VAR_GLOBAL;
+ if (! var)
+ {
+ if (grub_env_set (name, "") != GRUB_ERR_NONE)
+ return grub_errno;
+ var = grub_env_find (name);
+ }
+ var->type = GRUB_ENV_VAR_GLOBAL;
return GRUB_ERR_NONE;
}
I just noticed that I forgot the header line of the diff. Sorry for that. New double checked version attached.
The Changelog is still:
2009-12-15 Andreas Born <[email protected]>
* kern/env.c (grub_env_export): Create nonexistent variables
before exporting.
Quoted 53 lines · Andreas Born
Same here. Nothing changed as of r1917 and I didn't get any further feedback either. I've attached a rediffed version, too.
Quoted 48 lines · Andreas Born
Here you go:
ChangeLog:
2009-10-15 Andreas Born <[email protected]>*
kern/env.c(grub_env_export): Create nonexistent variables
before exporting.The mixed indentation (tabs and spaces) in
kern/env.cwas a bit confusing.Andreas
Quoted 34 lines · Colin Watson
Quoted 3 lines · Andreas Born
This patch changes
grub_env_exportto create variables with empty value, if necessary.
This makes it possible to export variables before actually assigning them any value and is the way bash behaves.This makes sense to me (although bash is "too big and too slow" and we'll never implement anything close to all of it, this is a pretty cheap way to reduce confusion due to differences), although probably for post-1.97. A couple of nits:
Quoted 3 lines
*
kern/env.c(grub_env_export): Create inexistent variables
before exporting."nonexistent"
Review
Quoted 6 lines
(quoted diff) +6
-0+ if (! var) + { + if (grub_env_set (name, "") != GRUB_ERR_NONE) + return grub_errno; + var = grub_env_find (name); + }GNU brace style involves indenting the braces as well, thus:
if (! var) { if (grub_env_set (name, "") != GRUB_ERR_NONE) return grub_errno; var = grub_env_find (name); }
=== modified file 'kern/env.c'
env.c +7 -2
@@ -170,8 +171,13 @@struct grub_env_var *var; var =grub_env_find (name); -if (var) - var->type =GRUB_ENV_VAR_GLOBAL ; +if (! var) + { +if (grub_env_set (name,"" ) !=GRUB_ERR_NONE ) +return grub_errno; + var =grub_env_find (name); + } + var->type =GRUB_ENV_VAR_GLOBAL ;return GRUB_ERR_NONE ; }
Quoted 3 lines · Andreas Born
I just noticed that I forgot the header line of the diff. Sorry for that. New double checked version attached.
Applied with stylistic fixes
Quoted 72 lines
The Changelog is still:
2009-12-15 Andreas Born <[email protected]>*
kern/env.c(grub_env_export): Create nonexistent variables
before exporting.Quoted 4 lines · Andreas Born
Same here. Nothing changed as of r1917 and I didn't get any further feedback either.
I've attached a rediffed version, too.Quoted 54 lines
Quoted 52 lines · Andreas Born
Here you go:
ChangeLog:
2009-10-15 Andreas Born <[email protected]>*
kern/env.c(grub_env_export): Create nonexistent variables
before exporting.The mixed indentation (tabs and spaces) in
kern/env.cwas a bit confusing.Andreas
Quoted 37 lines · Colin Watson
Quoted 5 lines · Andreas Born
This patch changes
grub_env_exportto create variables with empty value, if necessary.
This makes it possible to export variables before actually assigning them any value and is the way bash behaves.This makes sense to me (although bash is "too big and too slow" and we'll never implement anything close to all of it, this is a pretty cheap way to reduce confusion due to differences), although probably for
post-1.97. A couple of nits:Quoted 3 lines
*
kern/env.c(grub_env_export): Create inexistent
variables before exporting."nonexistent"
env.c line 179
Quoted 6 lines
env.c +6
-0+if (! var) + { +if (grub_env_set (name,"" ) !=GRUB_ERR_NONE ) +return grub_errno; + var =grub_env_find (name); + }GNU brace style involves indenting the braces as well, thus:
if (! var) { if (grub_env_set (name, "") != GRUB_ERR_NONE) return grub_errno; var = grub_env_find (name); }------------------------------------------------------------------------
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko