From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oPAew-0007N9-E8 for mharc-grub-devel@gnu.org; Fri, 19 Aug 2022 18:40:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oPAeq-0007N0-Cp for grub-devel@gnu.org; Fri, 19 Aug 2022 18:40:04 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:45893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oPAeb-0000Qm-Fb for grub-devel@gnu.org; Fri, 19 Aug 2022 18:40:03 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id de16so2000042qvb.12 for ; Fri, 19 Aug 2022 15:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=qQ1h45dMs52gW9XgpI/MAxRh2oEZHWU9oxFXRNpg4CQ=; b=q3sA+4H2kW163vfH8E9cbUlP09cDh9Ak2wAm7T+4JyqL4QSMNpq1Mq+6NLjBnkqiDp odIGHEV9/jI6wQlqYF1mqRK1NGhWU2ArQov8lzJINzqgCByxfxisYH4gP8Sz0OEyyNIP o8ZdF67JGx8s+T5IR8qQe1z5RwKpqajZbPSe4SuMFm0HoQWQ4ZtXKq2X2FqLm3SNsPDq nFZpPO1Hl6FHrhWD/CJpI7ITZGrB4ORLr6tchMZoJa28cEHmeN4BWTemIlpXtNgX+QYE zJypaBk+5VxIKs019IdzvudPePVt0oEjsFLjz+BjtK3MQ3Kr4E5LpXuZeSFKLAA6RIED Dx+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=qQ1h45dMs52gW9XgpI/MAxRh2oEZHWU9oxFXRNpg4CQ=; b=rRoxKEKAjL/9zpWtvOVeYlNF0f4Z8sxA19missqoc3aVonflNvQri55w19nyIUggQt 0TkYpB6MkOaMlheZp+HdboAI8n+3fIRcM6kb2PLBiFpeYm/J+ygsggA/auawrWpC6SSH C6iXoH1f3z39YmVuXrTZfnslD/oFhlWhrnrifSQkcp7FuZKrOo2t96BHxdm2AmkBDR3Y MdVt2r1MJJoUImrHzThpvszuJdmJGmaj9BTEYFk3KAvSGoqie72kUV3Lr6qlgsDU5/8Q ADOU+B7KcpXRSvuv2B9ytf2ka5JtsDL0J9J4fTXTLIAI/yFfB7CWFDHsKx/5++yy6dp3 HeoQ== X-Gm-Message-State: ACgBeo2/+kGclE+9afeIzO8MFHwZtFcT+LCtxpaww8U2Izr6gRT3u29o XpwK4guoWH8dRX7lmfDXffrAcWEUCyRwXA== X-Google-Smtp-Source: AA6agR7i11WL0PLwGSXBECzQNXmV0vLB9Yw1aYSgNyURbwqSc+Gk4dQproGAzQTSzJAGuQrcwkf4OQ== X-Received: by 2002:a05:6214:226e:b0:474:9a8b:3853 with SMTP id gs14-20020a056214226e00b004749a8b3853mr8020254qvb.85.1660948787276; Fri, 19 Aug 2022 15:39:47 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id q205-20020a3743d6000000b006bb296e3298sm4310505qka.20.2022.08.19.15.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 15:39:46 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v2] grub-core/kern/corecmd: Quote variable values when displayed by the set command Date: Fri, 19 Aug 2022 17:38:24 -0500 Message-Id: <20220819223824.421556-1-development@efficientek.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=development@efficientek.com; helo=mail-qv1-xf2a.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2022 22:40:04 -0000 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 --- 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 fc54f43f2..10b595d6b 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 = grub_env_get (env->name); + grub_printf ("%s=\"%s\"\n", env->name, val ? val : ""); + } return 0; } -- 2.34.1