Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions silkd/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions silkd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ publish = false
[dependencies]
base64 = "0.22"
libc = "0.2"
memchr = "2"
notify = "6"
regex = "1"
serde = { version = "1", features = ["derive"] }
Expand Down
9 changes: 1 addition & 8 deletions silkd/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl Io {
return Err(io::Error::new(io::ErrorKind::UnexpectedEof, "shell exited"));
}
acc.extend_from_slice(&buf[..n]);
if let Some(pos) = find(&acc, mb) {
if let Some(pos) = memchr::memmem::find(&acc, mb) {
emit(&mut out, &mut frame, &acc[..pos]).await;
let mut rest = acc[pos + mb.len()..].to_vec();
while !rest.contains(&b'\n') && rest.len() < EXIT_TAIL_MAX {
Expand Down Expand Up @@ -304,13 +304,6 @@ async fn emit<W: AsyncWrite + Unpin>(out: &mut Option<&mut W>, frame: &mut Vec<u
}
}

fn find(haystack: &[u8], needle: &[u8]) -> Option<usize> {
if needle.is_empty() || haystack.len() < needle.len() {
return None;
}
haystack.windows(needle.len()).position(|w| w == needle)
}

/// POSIX single-quote quoting: wrap in '…', closing/reopening around any
/// embedded single quote.
fn shell_quote(s: &str) -> String {
Expand Down