From 86455818e51488863a0dbbb5d48952fd49202af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 9 Jan 2023 11:49:56 +0100 Subject: Don't add an extra :, make robust against grep aliases grep adds a final newline which the second tr turns into an extra : By using a null byte and telling grep to treat it as text we can avoid this. Also guard the grep against the alias in my shell :) --- modules/wsl-distro.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/wsl-distro.nix b/modules/wsl-distro.nix index da3cd42..917e52a 100644 --- a/modules/wsl-distro.nix +++ b/modules/wsl-distro.nix @@ -175,9 +175,9 @@ with lib; { # preserve $PATH from parent variables.PATH = [ "$PATH" ]; extraInit = '' - export WSLPATH=$(echo "$PATH" | tr ':' '\n' | grep -E "^${cfg.wslConf.automount.root}" | tr '\n' ':') + export WSLPATH=$(echo "$PATH" | tr ':' '\0' | command grep -a "^${cfg.wslConf.automount.root}" | tr '\0' ':') ${if cfg.interop.includePath then "" else '' - export PATH=$(echo "$PATH" | tr ':' '\n' | grep -vE "^${cfg.wslConf.automount.root}" | tr '\n' ':') + export PATH=$(echo "$PATH" | tr ':' '\0' | command grep -av "^${cfg.wslConf.automount.root}" | tr '\0' ':') ''} ''; }; -- cgit v1.2.3