From 8d2eb1ff56ad17fe20e7f42a2e4b9b790640e806 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 12 Nov 2019 12:45:48 +0100 Subject: [PATCH] nix dev-shell: Improve bash output parsing Fixes handling of '=' in unquoted strings and escaped characters in $'...' strings. --- src/nix/shell.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nix/shell.cc b/src/nix/shell.cc index 50d0f9c88..6fa471dfc 100644 --- a/src/nix/shell.cc +++ b/src/nix/shell.cc @@ -29,6 +29,8 @@ BuildEnvironment readEnvironment(const Path & path) std::set exported; + debug("reading environment file '%s'", path); + auto file = readFile(path); auto pos = file.cbegin(); @@ -41,10 +43,10 @@ BuildEnvironment readEnvironment(const Path & path) R"re((?:="((?:[^"\\]|\\.)*)")?\n)re"); static std::string simpleStringRegex = - R"re((?:[a-zA-Z0-9_/:\.\-1\+]*))re"; + R"re((?:[a-zA-Z0-9_/:\.\-\+=]*))re"; static std::string quotedStringRegex = - R"re((?:\$?'[^']*'))re"; + R"re((?:\$?'(?:[^'\\]|\\[abeEfnrtv\\'"?])*'))re"; static std::string arrayRegex = R"re((?:\(( *\[[^\]]+\]="(?:[^"\\]|\\.)*")*\)))re";