Reference · Files and processes
stdin
signature
stdin() -> str | error(str)What it does
All that is piped to a script, as text, read to the end: cat rows.csv | quillo run tool.qwe. Nothing piped is "". With read_line a script
reads a line at a time instead, and exit ends it with a status,
which makes it a command-line tool.
Examples
in a program
// cat words.txt | quillo run count.qwelet words = split(trim(lower(stdin())), " ")print(len(words))Edge cases
- Bytes that are not UTF-8 are replaced, as
read_filereplaces them. - From a terminal with nothing piped, it waits for what is typed, to the end (Ctrl-D).
- Once read, it is read: a second
stdin()gives"".
Errors
A program that serves is not a script: there, it is a runtime error, as the input is the terminal's and a request is not the one to read it.
in a program
route GET /x = stdin() // a 500: `stdin` is for a scriptChaining
stdin() | split("\n") gives its lines.
See also
read_line, exit, args, read_file
Thread
Thread 0 posts
On stdin(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo