From adafdb88f55e94f28f46d57c4432cf3dd57ebc60 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Wed, 17 Aug 2016 04:31:35 +0300 Subject: [PATCH] wrapPythonProgram: fix magical sed expression * Treat #! as all other comments; * Treat comma at the end as a multi-line marker; * Skip lines with a space at start (they are continuing previous lines); * Don't allow spaces in front of quotes or the first real statement. --- pkgs/top-level/python-packages.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 8f0b85af8c57..2674da51f777 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -53,7 +53,7 @@ in modules // { isSingle = elem quote [ "\"" "'\"'\"'" ]; endQuote = if isSingle then "[^\\\\]${quote}" else quote; in '' - /^ *[a-z]?${quote}/ { + /^[a-z]?${quote}/ { /${quote}${quote}|${quote}.*${endQuote}/{n;br} :${label}; n; /^${quote}/{n;br}; /${endQuote}/{n;br}; b${label} } @@ -73,11 +73,11 @@ in modules // { in '' 1 { - /^#!/!b; :r - /\\$/{N;br} - /__future__|^ *(#.*)?$/{n;br} + :r + /\\$|,$/{N;br} + /__future__|^ |^ *(#.*)?$/{n;br} ${concatImapStrings mkStringSkipper quoteVariants} - /^ *[^# ]/i ${replaceStrings ["\n"] [";"] preamble} + /^[^# ]/i ${replaceStrings ["\n"] [";"] preamble} } ''; }