Repository navigation
Description
A cell containing a newline splits its row, and the split is silent.
Reproduction
Every shell result carries a stdout field, and stdout ends in a newline. So this is the ordinary case,
not an edge one:
$ devlore-test run -o table --jq '.results' test_hello.star
COMMAND EXIT STDERR STDOUT
echo "Hello World!" 0 Hello World!
<- the row ended here, mid-record
Byte-level, the row is echo "Hello World!" 0 Hello World!\n followed by a second \n: the
cell's own newline terminated the line, and tabwriter then wrote the row's terminator onto the next one.
A reader sees one record rendered as two lines, with the second one blank.
Why csv is unaffected
csv quotes, so the newline lands inside the quoted field and a parser still reads one record:
command,exit,stderr,stdout
"echo ""Hello World!""",0,,"Hello World!
"
That is the quoting rationale that retired tsv, working exactly as argued.
value splits too, and that is correct: raw is raw, gcloud and aws behave the same, and the caller is
expected to project with --jq first. table has no such contract. It renders for a person, and a person
reading a split row is being misinformed about how many records there are.
The fix
Escape control characters in a table cell -- a newline as the two characters \n, a tab as \t, a
carriage return as \r. kubectl and aws both do this rather than wrap, and it keeps one record on one
line, which is the property that makes an aligned table readable at all.
Scope is pkg/result/table.go alone. csv must NOT change: RFC 4180 quoting already handles the case
correctly, and escaping there would corrupt a field that a parser round-trips today. value must not change
either, for the reason above.
Verification
- A cell containing
\nrenders on one line, in\nform. - The row count equals the record count.
csvstill emits the newline inside quotes, unescaped, and a CSV reader still parses one record.- Alignment stays rune-measured, so the escape does not reintroduce the byte-counting defect of lore search truncates descriptions by byte count, cutting multi-byte characters mid-rune #741.
Activity
fix(result): a table row survives its own newlines, and jq survives i…
Every presentation is a presentation of the JSON: formatting rules, l…