Aaronontheweb / Aaronontheweb/ShellSyntaxTree
Support structured control flow (loops) in Bash and PowerShell grammars
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 15
- Forks
- 0
- Ø Merge
- 9 Min.
- Gemergte PRs (30 T.)
- 7
Beschreibung
Problem
SPEC.md section 4 states v0.1 does not support control-flow keywords. for, while, do, done, then, fi, case, and esac set IsUnparseable = true.
The grammar is flat:
command := clause (compound_op clause)*
This is load-bearing for real consumers. NetClaw's shell approval gate walks parsed clauses to decide authorization. Commands that hit IsUnparseable fail closed to an approval prompt.
Why it matters
LLM agents emit loops and heredocs constantly. A production corpus of 45 approval-prompted shell commands showed 8 (18%) were for loops, heredocs, or process substitution. All tripped IsUnparseable.
Loops are static constructs. for f in *.txt; do rm "$f"; done does not hide a path behind $(). The approval risk is the body clause (rm). The existing clause model already evaluates that.
Request
Support structured control flow in both grammars:
- Bash:
for/while/until/if/casewithdo/done/then/else/fi/esac - PowerShell:
foreach/for/while/do/if/switch
Design intent: parse the loop header and expose body clauses as child clauses in the AST. The loop keyword adds no authorization scope. Consumers (approval gates) can walk body clauses with the same logic they use for && chains.
Priority
Corpus-based order for Bash: for loops first, then heredocs, then while / if. Also consider arithmetic expansion $(( ... )), which the same spec line excludes.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit Abschnitt 4 von SPEC.md und der bestehenden flachen Befehls-/Klauselgrammatik für Bash und PowerShell. Verfolgen Sie, wie IsUnparseable gesetzt wird und wie der AST Klauseln verfügbar macht; überprüfen Sie anschließend, dass die aufgeführten strukturierten Konstrukte untergeordnete Body-Klauseln erzeugen, die von approval-gate-Verbrauchern durchlaufen werden können, ohne IsUnparseable auszulösen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- bash, csharp, powershell
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100