diff options
Diffstat (limited to 'rs/shell')
| -rw-r--r-- | rs/shell/src/main.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/rs/shell/src/main.rs b/rs/shell/src/main.rs index b9c50d8..ef0ef48 100644 --- a/rs/shell/src/main.rs +++ b/rs/shell/src/main.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use std::{process::ExitCode, os::unix::process::CommandExt}; | 1 | use std::{os::unix::process::CommandExt, process::ExitCode}; |
| 2 | 2 | ||
| 3 | fn parse_sq(s: &str) -> Option<(String, &str)> { | 3 | fn parse_sq(s: &str) -> Option<(String, &str)> { |
| 4 | #[derive(PartialEq, Eq)] | 4 | #[derive(PartialEq, Eq)] |
| @@ -7,13 +7,13 @@ fn parse_sq(s: &str) -> Option<(String, &str)> { | |||
| 7 | Unquoted { may_escape: bool }, | 7 | Unquoted { may_escape: bool }, |
| 8 | UnquotedEscaped, | 8 | UnquotedEscaped, |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | let mut result = String::new(); | 11 | let mut result = String::new(); |
| 12 | let mut state = SqState::Unquoted { may_escape: false }; | 12 | let mut state = SqState::Unquoted { may_escape: false }; |
| 13 | let mut remaining = ""; | 13 | let mut remaining = ""; |
| 14 | for (i, c) in s.char_indices() { | 14 | for (i, c) in s.char_indices() { |
| 15 | match state { | 15 | match state { |
| 16 | SqState::Unquoted { may_escape: false} => { | 16 | SqState::Unquoted { may_escape: false } => { |
| 17 | if c != '\'' { | 17 | if c != '\'' { |
| 18 | return None; | 18 | return None; |
| 19 | } | 19 | } |
| @@ -26,7 +26,7 @@ fn parse_sq(s: &str) -> Option<(String, &str)> { | |||
| 26 | } | 26 | } |
| 27 | result.push(c); | 27 | result.push(c); |
| 28 | } | 28 | } |
| 29 | SqState::Unquoted { may_escape: true }=> { | 29 | SqState::Unquoted { may_escape: true } => { |
| 30 | if is_posix_space(c) { | 30 | if is_posix_space(c) { |
| 31 | remaining = &s[i..]; | 31 | remaining = &s[i..]; |
| 32 | break; | 32 | break; |
| @@ -47,7 +47,7 @@ fn parse_sq(s: &str) -> Option<(String, &str)> { | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | if state != (SqState::Unquoted { may_escape: true }) { | 49 | if state != (SqState::Unquoted { may_escape: true }) { |
| 50 | return None | 50 | return None; |
| 51 | } | 51 | } |
| 52 | Some((result, remaining)) | 52 | Some((result, remaining)) |
| 53 | } | 53 | } |