MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / split_proxy_command_words

Function split_proxy_command_words

crates/openshell-core/src/forward.rs:166–202  ·  view source on GitHub ↗
(input: &str)

Source from the content-addressed store, hash-verified

164/// Split shell words well enough to round-trip values emitted by [`shell_escape`].
165#[cfg(any(target_os = "linux", test))]
166fn split_proxy_command_words(input: &str) -> Vec<String> {
167 let mut words = Vec::new();
168 let mut current: Option<String> = None;
169 let mut chars = input.chars();
170 while let Some(c) = chars.next() {
171 match c {
172 c if c.is_whitespace() => {
173 if let Some(word) = current.take() {
174 words.push(word);
175 }
176 }
177 '\'' => {
178 let buf = current.get_or_insert_with(String::new);
179 for q in chars.by_ref() {
180 if q == '\'' {
181 break;
182 }
183 buf.push(q);
184 }
185 }
186 '"' => {
187 let buf = current.get_or_insert_with(String::new);
188 for q in chars.by_ref() {
189 if q == '"' {
190 break;
191 }
192 buf.push(q);
193 }
194 }
195 other => current.get_or_insert_with(String::new).push(other),
196 }
197 }
198 if let Some(word) = current.take() {
199 words.push(word);
200 }
201 words
202}
203
204#[derive(Debug, Clone, Copy)]
205struct ProxyCommandMatch {

Callers 1

expand_proxy_command_argFunction · 0.85

Calls 2

pushMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected