diff --git a/src/engines/bash-engine.cc b/src/engines/bash-engine.cc index 2f76e049..530eebcb 100644 --- a/src/engines/bash-engine.cc +++ b/src/engines/bash-engine.cc @@ -756,8 +756,17 @@ class BashEngine : public ScriptEngineBase if (!arithmeticActive && s.find("let ") != 0 && s.find("$((") == std::string::npos && s.find("))") == std::string::npos && heredocStart != std::string::npos) { - // Skip << and remove spaces before and after "EOF" - heredocMarker = trim_string(s.substr(heredocStart + 2, s.size())); + // Skip << + heredocMarker = s.substr(heredocStart + 2, s.size()); + + if (heredocMarker[0] == '-') + { + // '-' marks tab-suppression in heredoc + heredocMarker = heredocMarker.substr(1); + } + + // Remove spaces before and after "EOF" + heredocMarker = trim_string(heredocMarker); // Make sure the heredoc marker is a word for (unsigned int i = 0; i < heredocMarker.size(); i++) @@ -769,12 +778,6 @@ class BashEngine : public ScriptEngineBase } } - if (heredocMarker[0] == '-') - { - // '-' marks tab-suppression in heredoc - heredocMarker = heredocMarker.substr(1); - } - if (heredocMarker.length() > 2 && (heredocMarker[0] == '"' || heredocMarker[0] == '\'') && heredocMarker[0] == heredocMarker[heredocMarker.length() - 1]) {