readline

Reads a line from the terminal and return it, using prompt as a prompt. If prompt is NULL or the empty string, no prompt is issued. The line returned has the final newline removed, so only the text of the line remains.

Except for the note below, the documentation is taken from the manpage of readline. Refer to the readline manpage for more extensive documentation.

Note: If prompt isn't null-terminated and isn't null then it's converted to a C null-terminated string before passing it to the C readline function. Converting to C string might re-allocate the buffer. If you have tight memory constraints, it is highly recommended to provide a null terminated string or make sure that the GC block your buffer is stored in has a spare byte at the end.

Parameters

prompt mstring

the string to be prompted to the user (see note above)

buffer mstring

optional buffer to store the user input, if the buffer is null then it would be allocated only if the user provided an input.

Return Value

Type: mstring

Returns the text of the line read. A blank line returns empty string. If EOF is encountered while reading a line, and the line is empty, null is returned. If an EOF is read with a non-empty line, it is treated as a newline.

Meta