Aaronontheweb / Aaronontheweb/ShellSyntaxTree

Support structured control flow (loops) in Bash and PowerShell grammars

Aperta
#71 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement
Lingua principale
C#
Stelle
15
Fork
0
Merge medio
9m
PR unite (30g)
7

Descrizione

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 / case with do / 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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla sezione 4 di SPEC.md e dalla grammatica piatta esistente di comandi/clausole per Bash e PowerShell. Traccia come viene impostato IsUnparseable e come l’AST espone le clausole; quindi verifica che i costrutti strutturati elencati producano clausole body figlie che i consumer di approval-gate possano attraversare senza attivare IsUnparseable.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
bash, csharp, powershell
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.