Loading src/shell.cpp +17 −2 Changes for src/shell.cpp: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -2890,8 +2890,23 @@ int fresh::Shell::runSegmentWords(const std::string &input,const std::vector<She int depth=1; size_t closeIdx=to; for(size_t i=from+1;i<to;++i){ if(words[i].text=="{") ++depth; else if(words[i].text=="}"){ // Only at a statement-start position (right after ';'/'&&'/ // '||', or immediately after the opening '{'/keyword itself) // does a bare "{"/"}" count as real compound-command syntax // here -- same guard collectFunctionDefinitions()'s own // "atStmtStart" already applies for the identical reason (see // its comment): otherwise an ORDINARY argument word that just // happens to equal "}" (rare) or, far more commonly, a // "done"/"fi"/"esac" arriving via the OUTER loop just below // this one applying the SAME missing guard (e.g. "{ cmd | cmd2 // ; echo done; }" -- "done" here is plainly cat's own // argument, not a real while-loop terminator) would desync // this depth count and either close the group too early or // (as observed) miss the real closing '}' entirely. bool atStmtStart=(words[i-1].text==";" || words[i-1].text=="&&" || words[i-1].text=="||"); if(atStmtStart && words[i].text=="{") ++depth; else if(atStmtStart && words[i].text=="}"){ if(--depth==0){ closeIdx=i; break; } } } Loading Loading
src/shell.cpp +17 −2 Changes for src/shell.cpp: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -2890,8 +2890,23 @@ int fresh::Shell::runSegmentWords(const std::string &input,const std::vector<She int depth=1; size_t closeIdx=to; for(size_t i=from+1;i<to;++i){ if(words[i].text=="{") ++depth; else if(words[i].text=="}"){ // Only at a statement-start position (right after ';'/'&&'/ // '||', or immediately after the opening '{'/keyword itself) // does a bare "{"/"}" count as real compound-command syntax // here -- same guard collectFunctionDefinitions()'s own // "atStmtStart" already applies for the identical reason (see // its comment): otherwise an ORDINARY argument word that just // happens to equal "}" (rare) or, far more commonly, a // "done"/"fi"/"esac" arriving via the OUTER loop just below // this one applying the SAME missing guard (e.g. "{ cmd | cmd2 // ; echo done; }" -- "done" here is plainly cat's own // argument, not a real while-loop terminator) would desync // this depth count and either close the group too early or // (as observed) miss the real closing '}' entirely. bool atStmtStart=(words[i-1].text==";" || words[i-1].text=="&&" || words[i-1].text=="||"); if(atStmtStart && words[i].text=="{") ++depth; else if(atStmtStart && words[i].text=="}"){ if(--depth==0){ closeIdx=i; break; } } } Loading