aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nix/develop.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/nix/develop.cc b/src/nix/develop.cc
index 380417c82..32669414b 100644
--- a/src/nix/develop.cc
+++ b/src/nix/develop.cc
@@ -39,21 +39,24 @@ BuildEnvironment readEnvironment(const Path & path)
static std::string varNameRegex =
R"re((?:[a-zA-Z_][a-zA-Z0-9_]*))re";
- static std::regex declareRegex(
- "^declare -x (" + varNameRegex + ")" +
- R"re((?:="((?:[^"\\]|\\.)*)")?\n)re");
-
static std::string simpleStringRegex =
R"re((?:[a-zA-Z0-9_/:\.\-\+=]*))re";
- static std::string quotedStringRegex =
+ static std::string dquotedStringRegex =
+ R"re((?:\$?"(?:[^"\\]|\\[$`"\\\n])*"))re";
+
+ static std::string squotedStringRegex =
R"re((?:\$?'(?:[^'\\]|\\[abeEfnrtv\\'"?])*'))re";
static std::string indexedArrayRegex =
R"re((?:\(( *\[[0-9]+\]="(?:[^"\\]|\\.)*")*\)))re";
+ static std::regex declareRegex(
+ "^declare -a?x (" + varNameRegex + ")(=(" +
+ dquotedStringRegex + "|" + indexedArrayRegex + "))?\n");
+
static std::regex varRegex(
- "^(" + varNameRegex + ")=(" + simpleStringRegex + "|" + quotedStringRegex + "|" + indexedArrayRegex + ")\n");
+ "^(" + varNameRegex + ")=(" + simpleStringRegex + "|" + squotedStringRegex + "|" + indexedArrayRegex + ")\n");
/* Note: we distinguish between an indexed and associative array
using the space before the closing parenthesis. Will