Read and include files in a prompt

include_file(prompt, anyFile)

Arguments

prompt

A vector of strings.

anyFile

A boolean of the same length of prompt indicating that an instruction "ff:" has been detected in a string.

Value

A vector of strings containing prompt augmented by the files refered to in the original prompt.

Details

If anyFile[i] is TRUE then the sequence of characters following the instruction "ff:" in prompt[i] is read until the next space or the end of the string. This extracted string is assumed to be a file name. This file is looked for in the current working directory or any of its sub-directories. Once detected, the file is read with readLines() and this content is inserted in prompt between prompt[i-1] and prompt[i+1]. Note that prompt[i] is therefore deleted.

The result is returned.