Skip to main content

command_word

Function command_word 

Source
pub fn command_word(segment: &str) -> Option<String>
Expand description

Quote-aware command word of a command segment.

Tokenizes segment into words while respecting quotes and backslash escapes, skips leading variable assignments (including quoted values like FOO='hello world'), and returns the first non-assignment word, unquoted (e.g. python for 'python' or "python"). Returns None when the segment is empty or consists only of assignments.