Skip to content

Stdin

The process's standard input.

Obtained as shell.stdin.

Every handle reads through one shared buffered reader, so mixing iteration with read picks up exactly where the other left off. What differs between handles is only how they frame that stream.

Methods

(eq) other

Compares two handles, which are equal when they frame the stream the same way.

(iter)()

Iterates the stream, yielding lines by default.

A line includes its terminator, so chomp is how you ask for one without:

for line = shell.stdin.chomp()
  if (line == "--")
    break
let body = shell.stdin.read()

(next)()

Yields the next line or chunk.

chunks() -> Stdin

Returns a handle that yields arbitrary-sized Bin chunks.

Example

for chunk = shell.stdin.chunks()
  hasher.update $chunk

lines() -> Stdin

Returns a handle that yields lines.

This is the default framing, so it is only needed to undo a previous chunks.

read … -> Bin

Reads raw bytes.

With a size this is a single read, which may return fewer bytes than asked for, as fs.File.read does. Without one it reads to end of stream.

Parameters

NameTypeDescription
size? Int Maximum bytes to read. Unbounded when omitted.

Returns

An empty value at the end of the stream.

Example

let rest = shell.stdin.read()
let head = shell.stdin.read 64