Skip to main content

parse_echo_args

Function parse_echo_args 

Source
pub fn parse_echo_args(args: &[String]) -> (EchoConfig, &[String])
Expand description

Parse the raw command-line arguments (after the program name) into an EchoConfig and the remaining text arguments.

GNU echo uses manual flag parsing: a leading argument is only treated as flags if it starts with - and every subsequent character is one of n, e, or E. Combined flags like -neE are valid. Anything else (e.g. -z, --foo, or even -) is treated as a normal text argument.

When POSIXLY_CORRECT is set, escapes are always interpreted. GNU coreutils 9.x: if the FIRST arg is exactly ā€œ-nā€, recognize it and subsequent option-like args (including combined flags like -nE, -ne). Only -n has effect (suppress newline); -e/-E are consumed but ignored (escapes stay on). If the first arg is NOT ā€œ-nā€, no options recognized.