MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / extractSedExpressions

Function extractSedExpressions

tools/bash/sed_validation.go:46–73  ·  view source on GitHub ↗
(command string)

Source from the content-addressed store, hash-verified

44}
45
46func extractSedExpressions(command string) []string {
47 var expressions []string
48 tokens := Tokenize(command, true)
49 for i := 0; i < len(tokens); {
50 token := tokens[i]
51 switch {
52 case token == "sed":
53 i++
54 case token == "-e" || token == "--expression":
55 if i+1 < len(tokens) {
56 expressions = append(expressions, tokens[i+1])
57 i += 2
58 } else {
59 i++
60 }
61 case token == "-f" || token == "--file":
62 return nil
63 case strings.HasPrefix(token, "-"):
64 i++
65 default:
66 if looksLikeSedScript(token) {
67 expressions = append(expressions, token)
68 }
69 i++
70 }
71 }
72 return expressions
73}
74
75func validateSingleSedExpression(expr string, hasInplace bool) SedValidationResult {
76 if expr == "" {

Callers 1

ValidateSedCommandFunction · 0.85

Calls 2

TokenizeFunction · 0.85
looksLikeSedScriptFunction · 0.85

Tested by

no test coverage detected