Loading src/shell.cpp +11 −6 Changes for src/shell.cpp: 11 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -2367,7 +2367,7 @@ bool fresh::needsMoreInput(const std::string &text){ std::string heredocDelim; bool inHeredoc=false; static const char *openers[]={"if","for","while","case","{"}; static const char *openers[]={"if","for","while","until","case","{"}; static const char *closers[]={"fi","done","esac","}"}; auto isBoundary=[&](size_t pos)->bool{ Loading Loading @@ -2419,7 +2419,8 @@ bool fresh::needsMoreInput(const std::string &text){ text[wordStart-1]!=';' && text[wordStart-1]!='\n' && text[wordStart-1]!='|') --wordStart; std::string word=text.substr(wordStart,wordEnd-wordStart); if(word=="if" || word=="elif" || word=="while") if(word=="if" || word=="elif" || word=="while" || word=="until" || word=="do" || word=="then" || word=="else" || word=="!") return true; } return false; Loading Loading @@ -3370,7 +3371,9 @@ int fresh::Shell::runSegmentWords(const std::string &input,const std::vector<She words[i-1].text=="&&" || words[i-1].text=="||" || words[i-1].text=="|" || words[i-1].text=="if" || words[i-1].text=="elif" || words[i-1].text=="while"); words[i-1].text=="while" || words[i-1].text=="until" || words[i-1].text=="do" || words[i-1].text=="then" || words[i-1].text=="else" || words[i-1].text=="!"); if(atStmtStart && words[i].text=="{") ++depth; else if(atStmtStart && words[i].text=="}"){ if(--depth==0){ closeIdx=i; break; } Loading Loading @@ -3521,7 +3524,9 @@ void fresh::Shell::collectFunctionDefinitions(const std::string &input,std::vect words[i-1].text=="&&" || words[i-1].text=="||" || words[i-1].text=="|" || words[i-1].text=="if" || words[i-1].text=="elif" || words[i-1].text=="while"; words[i-1].text=="while" || words[i-1].text=="until" || words[i-1].text=="do" || words[i-1].text=="then" || words[i-1].text=="else" || words[i-1].text=="!"; if(depth==0 && atStmtStart){ std::string name; Loading Loading @@ -3584,7 +3589,7 @@ void fresh::Shell::collectFunctionDefinitions(const std::string &input,std::vect ++bodyEnd; } ok=(bd==0); }else if(bw=="if" || bw=="for" || bw=="while" || bw=="case"){ }else if(bw=="if" || bw=="for" || bw=="while" || bw=="until" || bw=="case"){ std::string closer=(bw=="if") ? "fi" : (bw=="case") ? "esac" : "done"; size_t closeIdx=findShellKeyword(words,bodyStart+1,words.size(),closer); if(closeIdx<words.size()){ Loading Loading @@ -3633,7 +3638,7 @@ void fresh::Shell::collectFunctionDefinitions(const std::string &input,std::vect // arriving via echo, a variable's value, etc.) desyncs this depth // count, throwing off whether a LATER real function header // anywhere else in this same input is seen at depth 0 or not. if(atStmtStart && (w=="if" || w=="for" || w=="while" || w=="case" || w=="{")) if(atStmtStart && (w=="if" || w=="for" || w=="while" || w=="until" || w=="case" || w=="{")) ++depth; else if(atStmtStart && depth>0 && (w=="fi" || w=="done" || w=="esac" || w=="}")) --depth; Loading Loading
src/shell.cpp +11 −6 Changes for src/shell.cpp: 11 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -2367,7 +2367,7 @@ bool fresh::needsMoreInput(const std::string &text){ std::string heredocDelim; bool inHeredoc=false; static const char *openers[]={"if","for","while","case","{"}; static const char *openers[]={"if","for","while","until","case","{"}; static const char *closers[]={"fi","done","esac","}"}; auto isBoundary=[&](size_t pos)->bool{ Loading Loading @@ -2419,7 +2419,8 @@ bool fresh::needsMoreInput(const std::string &text){ text[wordStart-1]!=';' && text[wordStart-1]!='\n' && text[wordStart-1]!='|') --wordStart; std::string word=text.substr(wordStart,wordEnd-wordStart); if(word=="if" || word=="elif" || word=="while") if(word=="if" || word=="elif" || word=="while" || word=="until" || word=="do" || word=="then" || word=="else" || word=="!") return true; } return false; Loading Loading @@ -3370,7 +3371,9 @@ int fresh::Shell::runSegmentWords(const std::string &input,const std::vector<She words[i-1].text=="&&" || words[i-1].text=="||" || words[i-1].text=="|" || words[i-1].text=="if" || words[i-1].text=="elif" || words[i-1].text=="while"); words[i-1].text=="while" || words[i-1].text=="until" || words[i-1].text=="do" || words[i-1].text=="then" || words[i-1].text=="else" || words[i-1].text=="!"); if(atStmtStart && words[i].text=="{") ++depth; else if(atStmtStart && words[i].text=="}"){ if(--depth==0){ closeIdx=i; break; } Loading Loading @@ -3521,7 +3524,9 @@ void fresh::Shell::collectFunctionDefinitions(const std::string &input,std::vect words[i-1].text=="&&" || words[i-1].text=="||" || words[i-1].text=="|" || words[i-1].text=="if" || words[i-1].text=="elif" || words[i-1].text=="while"; words[i-1].text=="while" || words[i-1].text=="until" || words[i-1].text=="do" || words[i-1].text=="then" || words[i-1].text=="else" || words[i-1].text=="!"; if(depth==0 && atStmtStart){ std::string name; Loading Loading @@ -3584,7 +3589,7 @@ void fresh::Shell::collectFunctionDefinitions(const std::string &input,std::vect ++bodyEnd; } ok=(bd==0); }else if(bw=="if" || bw=="for" || bw=="while" || bw=="case"){ }else if(bw=="if" || bw=="for" || bw=="while" || bw=="until" || bw=="case"){ std::string closer=(bw=="if") ? "fi" : (bw=="case") ? "esac" : "done"; size_t closeIdx=findShellKeyword(words,bodyStart+1,words.size(),closer); if(closeIdx<words.size()){ Loading Loading @@ -3633,7 +3638,7 @@ void fresh::Shell::collectFunctionDefinitions(const std::string &input,std::vect // arriving via echo, a variable's value, etc.) desyncs this depth // count, throwing off whether a LATER real function header // anywhere else in this same input is seen at depth 0 or not. if(atStmtStart && (w=="if" || w=="for" || w=="while" || w=="case" || w=="{")) if(atStmtStart && (w=="if" || w=="for" || w=="while" || w=="until" || w=="case" || w=="{")) ++depth; else if(atStmtStart && depth>0 && (w=="fi" || w=="done" || w=="esac" || w=="}")) --depth; Loading