Next: , Previous: String Ports, Up: Procedures


7.3.4 Line I/O

(require 'line-i/o)

— Function: read-line
— Function: read-line port

Returns a string of the characters up to, but not including a newline or end of file, updating port to point to the character following the newline. If no characters are available, an end of file object is returned. The port argument may be omitted, in which case it defaults to the value returned by current-input-port.

— Procedure: read-line! string
— Procedure: read-line! string port

Fills string with characters up to, but not including a newline or end of file, updating the port to point to the last character read or following the newline if it was read. If no characters are available, an end of file object is returned. If a newline or end of file was found, the number of characters read is returned. Otherwise, #f is returned. The port argument may be omitted, in which case it defaults to the value returned by current-input-port.

— Function: write-line string
— Function: write-line string port

Writes string followed by a newline to the given port and returns an unspecified value. The Port argument may be omitted, in which case it defaults to the value returned by current-input-port.

— Function: system->line command tmp
— Function: system->line command

command must be a string. The string tmp, if supplied, is a path to use as a temporary file. system->line calls system with command as argument, redirecting stdout to file tmp. system->line returns a string containing the first line of output from tmp.

system->line is intended to be a portable method for getting one-line results from programs like pwd, whoami, hostname, which, identify, and cksum. Its behavior when called with programs which generate lots of output is unspecified.