* [PATCH v3] grub-core/kern/corecmd: Quote variable values when displayed by the set command
@ 2022-08-26 0:53 Glenn Washburn
2022-10-06 13:32 ` Daniel Kiper
0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2022-08-26 0:53 UTC (permalink / raw)
To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn
Variable values may contain spaces at the end or newlines. However, when
displayed without quotes this is not obvious and can lead to confusion as
to the actual contents of variables. Also for some variables grub_env_get()
returns a NULL pointer instead of a pointer to an empty string and
previously would be printed as "var=(null)". Now such variables will be
displayed as "var=''".
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
v2->v3: cast away constness when assigning var to fix compiler error
---
grub-core/kern/corecmd.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c
index fc54f43f2b..62d434ba9a 100644
--- a/grub-core/kern/corecmd.c
+++ b/grub-core/kern/corecmd.c
@@ -40,7 +40,10 @@ grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
{
struct grub_env_var *env;
FOR_SORTED_ENV (env)
- grub_printf ("%s=%s\n", env->name, grub_env_get (env->name));
+ {
+ val = (char *) grub_env_get (env->name);
+ grub_printf ("%s='%s'\n", env->name, val == NULL ? "" : val);
+ }
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] grub-core/kern/corecmd: Quote variable values when displayed by the set command
2022-08-26 0:53 [PATCH v3] grub-core/kern/corecmd: Quote variable values when displayed by the set command Glenn Washburn
@ 2022-10-06 13:32 ` Daniel Kiper
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2022-10-06 13:32 UTC (permalink / raw)
To: Glenn Washburn; +Cc: grub-devel
On Thu, Aug 25, 2022 at 07:53:51PM -0500, Glenn Washburn wrote:
> Variable values may contain spaces at the end or newlines. However, when
> displayed without quotes this is not obvious and can lead to confusion as
> to the actual contents of variables. Also for some variables grub_env_get()
> returns a NULL pointer instead of a pointer to an empty string and
> previously would be printed as "var=(null)". Now such variables will be
> displayed as "var=''".
>
> Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-06 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-26 0:53 [PATCH v3] grub-core/kern/corecmd: Quote variable values when displayed by the set command Glenn Washburn
2022-10-06 13:32 ` Daniel Kiper
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.