Skip to main content

gethere

Function gethere 

Source
pub fn gethere(strp: &mut String, typ: i32) -> Option<String>
Expand description

Convert a here-document into a here-string. Line-by-line port of gethere() from Src/exec.c:4569-4652. Reads the body from the input stream via hgetc() until the terminator line is matched, returning the collected body as a string. strp is in/out: on entry the raw terminator (possibly with token markers + leading tabs); on return the munged terminator (after quotesubst + untokenize and, for REDIR_HEREDOCDASH, leading-tab strip).

Returns None on out-of-memory (C zalloc/realloc failure). Rust’s String auto-grows so the OOM branch is effectively unreachable, but the return type stays Option<String> to mirror the C signature which can return NULL.

Port of gethere(char **strp, int typ) from Src/exec.c:4573.