fix(rules): prevent appending empty command parts in forEachPipePart and remove redundant calculation in parseDoWithBlocks function

This commit is contained in:
yusing
2026-02-24 02:05:18 +08:00
parent 458c7779d3
commit 7b0d846576
2 changed files with 3 additions and 5 deletions

View File

@@ -417,10 +417,6 @@ func parseDoWithBlocks(src string) (handlers []CommandHandler, err error) {
}
// Not a nested block; parse the rest of this line as a command.
lineEnd = pos
for lineEnd < length && src[lineEnd] != '\n' {
lineEnd++
}
if lerr := appendLineCommand(src[pos:lineEnd]); lerr != nil {
return nil, lerr
}

View File

@@ -651,7 +651,9 @@ func forEachPipePart(s string, fn func(part string)) {
}
case '|':
if quote == 0 && brackets == 0 {
fn(strings.TrimSpace(s[start:i]))
if part := strings.TrimSpace(s[start:i]); part != "" {
fn(part)
}
start = i + 1
}
}