You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
one-liners: no file operands (awk/sed FILE…), no FILENAME/fnr, no -i in-place edit — §18.5b forbids the combination #958
sed -i 's/a/b/' file and awk '{…}' file1 file2 have no With spelling: every -n/-p invocation reads stdin only, and a file operand is refused:
$ with -n 'if nr == 1: print(line)' in.txt
error: cannot combine one-liner code with a source file
$ with -p -i 'line = line.replace("alpha", "ALPHA")' edit.txt
error: cannot combine one-liner code with a source file
Today the workarounds are < file (one file, no name) and a with run tool.w script with read_file/write_file for in-place edits — exactly the ceremony the one-liner modes exist to remove (CLAUDE.md: "Never sed/awk for text transforms — use a with one-liner").
Spec
§18.5b states "One-liner code cannot be combined with a source file argument." — the rule that produces the error. Trailing operands after -n/-p CODE are unambiguous (they are inputs, never the source: the source is the flag's value), so the sentence can narrow to "… with a source file argument; trailing operands are input files" without touching -e. That is a spec change: Eric blesses the words.
Proposal
with -n CODE FILE… / with -p CODE FILE…: iterate the files in order (stdin when none); bind filename: str and fnr: i64 (per-file line number) beside nr, awk's FILENAME/FNR.
-i: with -p, write each file's transformed lines back in place through a temp sibling + rename (the install kind's discipline), never a truncate-in-place; refuse -i without a file operand and with -n/-e.
Acceptance in the cli-selfhost-one-liner-tests lane: the two commands above succeed, -i leaves the file with the replacement and no temp sibling, filename/fnr print correctly across two files.
Found by the 2026-09-03 sed/awk parity matrix; companions #957 (state/END) and #959 (fields/parsing).
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced, and the next step is a spec ruling.
$ with -n 'print(line)' in.txt
error: cannot combine one-liner code with a source file
rc=1
What the spec says. §18.5b.3 and §18.5b.4 (docs/spec/018_modules.md) define -n and -p as loops over stdin.lines() only. No sentence makes a trailing operand an input file, and there is no -i. The compiler conforms.
The question. Should §18.5b say that trailing operands after -n/-p CODE are input files read in order, with filename and fnr bound per file, and that -i rewrites each file in place through a temporary sibling and a rename? That is improve_oneliners.md item 2. Until then sed -i and awk … file have no spelling except < file.
Activity
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced, and the next step is a spec ruling.What the spec says. §18.5b.3 and §18.5b.4 (
docs/spec/018_modules.md) define-nand-pas loops overstdin.lines()only. No sentence makes a trailing operand an input file, and there is no-i. The compiler conforms.The question. Should §18.5b say that trailing operands after
-n/-p CODEare input files read in order, withfilenameandfnrbound per file, and that-irewrites each file in place through a temporary sibling and a rename? That isimprove_oneliners.mditem 2. Until thensed -iandawk … filehave no spelling except< file.One-liners read files and edit them in place: operands after -n/-p co…