From b875e09927b4ff0ae01519b2fd74b9ea8428fd95 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Wed, 7 Sep 2022 18:52:30 -0400 Subject: [PATCH] Increase speed by using shell-words instead of shellwords --- Cargo.lock | 11 +++-------- Cargo.toml | 2 +- kakplugin/Cargo.toml | 2 +- kakplugin/src/errors.rs | 4 ++-- kakplugin/src/lib.rs | 3 ++- src/errors.rs | 4 ++-- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72205a9..54e7e4b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,7 +128,7 @@ dependencies = [ name = "kakplugin" version = "0.1.0" dependencies = [ - "shellwords", + "shell-words", ] [[package]] @@ -143,7 +143,6 @@ dependencies = [ "linked_hash_set", "rand", "regex", - "shellwords", "strum", "strum_macros", ] @@ -292,14 +291,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf" [[package]] -name = "shellwords" +name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e515aa4699a88148ed5ef96413ceef0048ce95b43fbc955a33bde0a70fcae6" -dependencies = [ - "lazy_static", - "regex", -] +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "strsim" diff --git a/Cargo.toml b/Cargo.toml index c54a7b3..ddcc8ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ regex = "1" clap = {version = "3", features = ["derive", "env"]} alphanumeric-sort = "1" # shellwords = {version = "1", path = "../../../git/rust-shellwords/"} -shellwords = "1" +# shellwords = "1" rand = "0.8" evalexpr = "7" kakplugin = {path = "./kakplugin/"} diff --git a/kakplugin/Cargo.toml b/kakplugin/Cargo.toml index b9269e0..651ea1f 100644 --- a/kakplugin/Cargo.toml +++ b/kakplugin/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -shellwords = "1" +shell-words = "1" diff --git a/kakplugin/src/errors.rs b/kakplugin/src/errors.rs index 5d4295d..cf69abc 100644 --- a/kakplugin/src/errors.rs +++ b/kakplugin/src/errors.rs @@ -68,8 +68,8 @@ impl From for KakError { } } -impl From for KakError { - fn from(e: shellwords::MismatchedQuotes) -> Self { +impl From for KakError { + fn from(e: shell_words::ParseError) -> Self { Self::Parse(format!("Shell could not be parsed: {e:?}")) } } diff --git a/kakplugin/src/lib.rs b/kakplugin/src/lib.rs index 58d5058..ca476aa 100644 --- a/kakplugin/src/lib.rs +++ b/kakplugin/src/lib.rs @@ -1,6 +1,7 @@ mod errors; pub mod types; pub use errors::KakError; +pub use shell_words::ParseError; use std::{ env, fs::{self, File, OpenOptions}, @@ -225,7 +226,7 @@ where ), })?; - Ok(shellwords::split(&fs::read_to_string(&get_var( + Ok(shell_words::split(&fs::read_to_string(&get_var( "kak_response_fifo", )?)?)?) } diff --git a/src/errors.rs b/src/errors.rs index bc76a80..6bff3f1 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -24,8 +24,8 @@ impl From<&str> for KakMessage { } } -impl From for KakMessage { - fn from(err: shellwords::MismatchedQuotes) -> Self { +impl From for KakMessage { + fn from(err: kakplugin::ParseError) -> Self { Self("Corrupt kak response".to_string(), Some(err.to_string())) } }