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

Offen
#167 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
66/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
rust
Bereich
cli

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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).

Vorherrschende Sprache
Rust
Sterne
31
Forks
13
Ø Merge
23 Std. 42 Min.
Gemergte PRs (30 T.)
29

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus uutils/awk

Alle Issues in uutils/awk

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.