#4112·marked

CLI --string with an empty value unexpectedly reads stdin

Author: xu91102Created Sep 26, 2026Updated Sep 26, 2026

Marked version: 18.0.14, master ef0704c58459e927c805b92a5cc7d0c629e6fe43

Markdown flavor: n/a (CLI input selection)

Expectation

An explicitly supplied empty string should be parsed as empty Markdown, without consuming stdin. This is useful when a script passes a possibly empty variable to marked --string "$text".

Result

bash
printf '# should be ignored' | marked --string ''

Outputs <h1>should be ignored</h1> instead of the normal empty CLI result (a newline). With an open terminal as stdin, the command waits for input even though --string was supplied.

Cause and reproduction

getData() checks if (string), so an empty option value falls through to file/stdin input. Checking whether the option is undefined preserves an explicitly supplied empty string.

Reproduced with the existing CLI test harness and a real Node.js child process on macOS. Nonempty string input and omission of --string should keep their existing behavior.