From 2583ea10b3b1ee87bc086a952a0fc3fe26521217 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 15 Nov 2022 01:11:33 +0100 Subject: lib/shell.fmt: escape text in formatted block --- lib/shell.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shell.nix b/lib/shell.nix index fd90034..e6ba22c 100644 --- a/lib/shell.nix +++ b/lib/shell.nix @@ -9,7 +9,7 @@ let concatStringsSep "\n" (mapAttrsToList mapping attrs); fmt = rec { - codeBlock = code: text: ''"\e[${code}m"${text}"\e[0m"''; + codeBlock = code: text: ''"\e[${code}m"${escapeShellArg text}"\e[0m"''; keyword = codeBlock "1;36"; section = codeBlock "4;35"; printSectionTitle = title: ''echo -e "\n\n"${section title}"\n"''; @@ -26,7 +26,7 @@ in rec { exportEnvVars = mapAttrsToLines exportEnvVar; printEnvVar = k: v: '' - echo -e ${fmt.keyword (escapeShellArg "$" + k)}: ${escapeShellArg v} + echo -e ${fmt.keyword ("$" + k)}: ${escapeShellArg v} ''; printEnvVars = envVars: '' -- cgit v1.2.3