Skip to content

shelldoc blocks indefinitely on command output with no trailing newline #78

@mirkoboehm

Description

@mirkoboehm

shelldoc reads command output line-by-line. If the final (or only) line if output is not terminated by \n, shelldoc blocks indefinitely waiting for the line terminator and eventually times out with ERROR: command execution timed out FAIL (timeout).

This affects any command that writes a bare value without a trailing newline. Two confirmed cases:

  • kubectl … -o jsonpath='{.field}' — emits the field value with no \n
  • curl -sf — when the response body is a bare JSON primitive such as true (4 bytes, no \n)

To reproduce:

$ printf 'no newline here'
no newline here

shelldoc times out after 5 seconds despite the expected output matching.

Workaround: append ; echo to the command in the exercise markdown (or in the Makefile target it calls) to guarantee a trailing newline.

Expected behaviour: shelldoc should treat EOF on the command's stdout as an implicit line terminator, flushing any buffered partial line as a complete output line.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions