From 8a4572991c3d095790fe0abb40f9f7b638da5b9c Mon Sep 17 00:00:00 2001 From: niansa Date: Sat, 2 May 2020 12:36:38 +0100 Subject: [PATCH] Fixed bug with # in string --- main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 4c60c83..9d58a2c 100644 --- a/main.cpp +++ b/main.cpp @@ -478,7 +478,9 @@ void init_interpreter(int argc, char *argv[]) { } std::string execline(std::string commandstr) { - commandstr = ltrim(commandstr.substr(0, commandstr.find("#", 0))); + commandstr = ltrim(commandstr); + if (commandstr[0] == '#') + return success; //std::cout << "$ " << commandstr << std::endl; if (rtrim(commandstr) == "") { // Command is empty return commandstr; @@ -508,13 +510,14 @@ std::string execline(std::string commandstr) { bool charig = false; bool skipall = false; for (std::string::iterator currchar = argsstr.begin(); currchar < argsstr.end(); currchar++) { - if (skipall) { + if (skipall and *currchar != ',') { continue; } else if (*currchar == '"' and !skipall) { instring = !instring; if (currarg == "") arginstring = true; } else if (*currchar == '#' and !charig and !instring) { + *(currchar + 1) = ','; skipall = true; } else if (*currchar == ',' and !charig and !instring) { if (currarg.length() != 0 and *currarg.begin() == '$' and !arginstring) {