From 2711b51437ddbb3d9d023c1e18b2af15e0959ed9 Mon Sep 17 00:00:00 2001 From: Brooklyn Zelenka Date: Tue, 13 Oct 2026 13:28:43 -0700 Subject: [PATCH] Escape shell strings --- lib/core.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/core.nix b/lib/core.nix index a5e67ae..0d267ae 100755 --- a/lib/core.nix +++ b/lib/core.nix @@ -1,6 +1,8 @@ { pkgs }: let + inherit (pkgs.lib) escapeShellArg; + cmd = description: script: { inherit description script; help = null; }; withHelp = help: def: def // { inherit help; }; @@ -13,9 +15,9 @@ let helpHandler = if help != null then '' if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then - echo "${name} - ${description}" + echo ${escapeShellArg "${name} - ${description}"} echo "" - echo "${help}" + echo ${escapeShellArg help} exit 0 fi '' else ""; @@ -27,7 +29,7 @@ let pkgs.writeScriptBin name '' #!${pkgs.bash}/bin/bash ${helpHandler} - echo "⚙️ Running ${name}..." + echo ${escapeShellArg "⚙️ Running ${name}..."} ${script} ''; }; @@ -108,7 +110,7 @@ let # Combine all lines allLines = [ topBorder headerRow headerSep ] ++ interleave dataRows ++ [ bottomBorder ]; - echoLines = builtins.concatStringsSep " && " (map (l: "echo '${l}'") allLines); + echoLines = builtins.concatStringsSep " && " (map (l: "echo ${escapeShellArg l}") allLines); in pkgs.writeScriptBin "menu" '' -- knotmirror 0.0.1