prepare_input

Function prepare_input 

Source
pub fn prepare_input<'s: 'i + 'e, 'i, 'e>(
    env: &'i RefCell<&mut Env>,
    source: &'s Source,
) -> Result<Lexer<'i>, PrepareInputError<'e>>
Expand description

Prepares the input for the shell syntax parser.

This function constructs a lexer from the given source with the following decorators applied to the input object:

  • If the source is read with a file descriptor, the Echo decorator is applied to the input to implement the Verbose shell option.
  • If the Interactive option is enabled and the source is read with a file descriptor, the Prompter decorator is applied to the input to show the prompt.
  • If the Interactive option is enabled, the Reporter decorator is applied to the input to show changes in job status before prompting for the next command.
  • If the Interactive option is enabled and the source is read with a file descriptor, the IgnoreEof decorator is applied to the input to implement the IgnoreEof shell option.

The RefCell passed as the first argument should be shared with (and only with) the read_eval_loop function that consumes the input and executes the parsed commands.