awk: a fatal runtime error still runs the END rules and exits 1 instead of 2

Aperta
#167 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

Start by locating the runtime error handling and the tests that exercise END rules; the issue provides a reproduction and a proposed regression test, but names no source or test file. Run the supplied test case and compare its exit status and stdout with the GNU awk behavior. Done means a fatal runtime error skips END rules, exits with status 2, and the regression test passes.

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

Descrizione

bug gnu-compat

After a fatal runtime error, such as using an array in a scalar context, GNU
awk stops right away and exits with status 2. uutils awk reports the error,
then runs the END rules and exits with status 1. An END rule that prints a
summary or writes a file therefore runs on half-processed data.

Reproduction

Rust (incorrect)

$ ./target/release/awk 'BEGIN { a[1] = 1; print a } END { print "end" }' </dev/null 2>/dev/null; echo $?
end
1

GNU (correct)

$ gawk 'BEGIN { a[1] = 1; print a } END { print "end" }' </dev/null 2>/dev/null; echo $?
2

Test

#[test]
fn fatal_error_skips_end() {
    ucmd()
        .arg("BEGIN { v[0] = 0; print v } END { print \"not reached\" }")
        .fails_with_code(2)
        .no_stdout();
}

Exposed by the GNU awk test suite: aryprm2, aryprm5, callparam, defref,
functab1, functab2, functab6, fwtest6, fwtest8, prmarscl, sclifin (they also
compare the message text).

Lingua principale
Rust
Stelle
31
Fork
13
Merge medio
23h 42m
PR unite (30g)
29

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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.

Altre issue di uutils/awk

Tutte le issue di uutils/awk

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.