* [PATCH] create variables when exporting them
@ 2009-10-15 18:40 Andreas Born
2009-10-15 19:16 ` Colin Watson
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Born @ 2009-10-15 18:40 UTC (permalink / raw)
To: GRUB2 Devel
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
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 <futur.andy@googlemail.com>
* kern/env.c (grub_env_export): Create inexistent variables
before exporting.
[-- Attachment #2: export-create.diff --]
[-- Type: text/x-patch, Size: 486 bytes --]
Index: kern/env.c
===================================================================
--- kern/env.c (Revision 2631)
+++ kern/env.c (Arbeitskopie)
@@ -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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] create variables when exporting them
2009-10-15 18:40 [PATCH] create variables when exporting them Andreas Born
@ 2009-10-15 19:16 ` Colin Watson
2009-10-15 19:52 ` Andreas Born
0 siblings, 1 reply; 6+ messages in thread
From: Colin Watson @ 2009-10-15 19:16 UTC (permalink / raw)
To: The development of GRUB 2
On Thu, Oct 15, 2009 at 08:40:37PM +0200, Andreas Born wrote:
> 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.
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:
> * kern/env.c (grub_env_export): Create inexistent variables
> before exporting.
"nonexistent"
> + 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);
}
--
Colin Watson [cjwatson@ubuntu.com]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] create variables when exporting them
2009-10-15 19:16 ` Colin Watson
@ 2009-10-15 19:52 ` Andreas Born
2009-12-06 22:57 ` Andreas Born
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Born @ 2009-10-15 19:52 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]
Here you go:
ChangeLog:
2009-10-15 Andreas Born <futur.andy@googlemail.com>
* 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
Colin Watson schrieb:
> On Thu, Oct 15, 2009 at 08:40:37PM +0200, Andreas Born wrote:
>
>> 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.
>>
>
> 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:
>
>
>> * kern/env.c (grub_env_export): Create inexistent variables
>> before exporting.
>>
>
> "nonexistent"
>
>
>> + 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);
> }
>
>
[-- Attachment #2: export-create.diff --]
[-- Type: text/x-patch, Size: 496 bytes --]
Index: kern/env.c
===================================================================
--- kern/env.c (Revision 2631)
+++ kern/env.c (Arbeitskopie)
@@ -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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] create variables when exporting them
2009-10-15 19:52 ` Andreas Born
@ 2009-12-06 22:57 ` Andreas Born
2009-12-15 18:20 ` Andreas Born
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Born @ 2009-12-06 22:57 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1546 bytes --]
Same here. Nothing changed as of r1917 and I didn't get any further
feedback either.
I've attached a rediffed version, too.
Andreas Born schrieb:
> Here you go:
> ChangeLog:
> 2009-10-15 Andreas Born <futur.andy@googlemail.com>
>
> * 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
>
> Colin Watson schrieb:
>> On Thu, Oct 15, 2009 at 08:40:37PM +0200, Andreas Born wrote:
>>
>>> 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.
>>>
>>
>> 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:
>>
>>
>>> * kern/env.c (grub_env_export): Create inexistent variables
>>> before exporting.
>>>
>>
>> "nonexistent"
>>
>>
>>> + 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);
>> }
>>
>
[-- Attachment #2: export-create.diff --]
[-- Type: text/x-patch, Size: 349 bytes --]
@@ -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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] create variables when exporting them
2009-12-06 22:57 ` Andreas Born
@ 2009-12-15 18:20 ` Andreas Born
2009-12-21 14:21 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Born @ 2009-12-15 18:20 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 1908 bytes --]
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 <futur.andy@googlemail.com>
* kern/env.c (grub_env_export): Create nonexistent variables
before exporting.
Andreas Born schrieb:
> Same here. Nothing changed as of r1917 and I didn't get any further
> feedback either.
> I've attached a rediffed version, too.
>
> Andreas Born schrieb:
>> Here you go:
>> ChangeLog:
>> 2009-10-15 Andreas Born <futur.andy@googlemail.com>
>>
>> * 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
>>
>> Colin Watson schrieb:
>>> On Thu, Oct 15, 2009 at 08:40:37PM +0200, Andreas Born wrote:
>>>
>>>> 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.
>>>>
>>>
>>> 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:
>>>
>>>
>>>> * kern/env.c (grub_env_export): Create inexistent variables
>>>> before exporting.
>>>>
>>>
>>> "nonexistent"
>>>
>>>
>>>> + 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);
>>> }
>>
>
[-- Attachment #2: export-create.diff --]
[-- Type: text/x-patch, Size: 462 bytes --]
=== modified file 'kern/env.c'
--- kern/env.c 2009-07-16 22:14:09 +0000
+++ kern/env.c 2009-11-29 00:15:05 +0000
@@ -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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] create variables when exporting them
2009-12-15 18:20 ` Andreas Born
@ 2009-12-21 14:21 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 0 replies; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2009-12-21 14:21 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]
Andreas Born wrote:
> I just noticed that I forgot the header line of the diff. Sorry for that.
> New double checked version attached.
>
Applied with stylistic fixes
> The Changelog is still:
> 2009-12-15 Andreas Born <futur.andy@googlemail.com>
>
> * kern/env.c (grub_env_export): Create nonexistent variables
> before exporting.
>
> Andreas Born schrieb:
>> Same here. Nothing changed as of r1917 and I didn't get any further
>> feedback either.
>> I've attached a rediffed version, too.
>>
>> Andreas Born schrieb:
>>> Here you go:
>>> ChangeLog:
>>> 2009-10-15 Andreas Born <futur.andy@googlemail.com>
>>>
>>> * 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
>>>
>>> Colin Watson schrieb:
>>>> On Thu, Oct 15, 2009 at 08:40:37PM +0200, Andreas Born wrote:
>>>>
>>>>> 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.
>>>>>
>>>>
>>>> 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:
>>>>
>>>>
>>>>> * kern/env.c (grub_env_export): Create inexistent
>>>>> variables before exporting.
>>>>>
>>>>
>>>> "nonexistent"
>>>>
>>>>
>>>>> + 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
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-12-21 14:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-15 18:40 [PATCH] create variables when exporting them Andreas Born
2009-10-15 19:16 ` Colin Watson
2009-10-15 19:52 ` Andreas Born
2009-12-06 22:57 ` Andreas Born
2009-12-15 18:20 ` Andreas Born
2009-12-21 14:21 ` Vladimir 'φ-coder/phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.