From cd4585f5cf475a03a0b071a7b9ea8243252da445 Mon Sep 17 00:00:00 2001 From: Kai Klingenberg Date: Sat, 18 Mar 2023 23:15:46 -0300 Subject: [PATCH] fix error in shell-splitting the handler command --- Cargo.lock | 2 +- Cargo.toml | 13 +------------ src/app.rs | 10 ++++++---- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0aec03..74ba530 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1478,7 +1478,7 @@ checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "s3-event-bridge" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "aws-config", diff --git a/Cargo.toml b/Cargo.toml index 799ed64..b24f080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,8 @@ [package] name = "s3-event-bridge" -version = "0.1.3" +version = "0.1.4" edition = "2021" -# Starting in Rust 1.62 you can use `cargo add` to add dependencies -# to your project. -# -# If you're using an older Rust version, -# download cargo-edit(https://github.com/killercup/cargo-edit#installation) -# to install the `add` subcommand. -# -# Running `cargo add DEPENDENCY_NAME` will -# add the latest version of a dependency to the list, -# and it will keep the alphabetic ordering for you. - [dependencies] anyhow = "1.0.69" aws-config = "0.54.1" diff --git a/src/app.rs b/src/app.rs index b0fda79..24b9902 100644 --- a/src/app.rs +++ b/src/app.rs @@ -10,6 +10,7 @@ use envy::from_env; use once_cell::sync::OnceCell; use regex::Regex; use std::cmp::max; +use std::collections::VecDeque; use tempfile::TempDir; use tokio::process::Command; use tracing::{info, instrument}; @@ -31,7 +32,7 @@ pub struct App { pub handler_command_program: String, /// The arguments passed to the executed handler program. - pub handler_command_args: Vec, + pub handler_command_args: VecDeque, } impl App { @@ -75,15 +76,16 @@ impl App { pull_match_key_res.push(Regex::new("")?) } // Parse handler command - let mut handler_command_args = + let mut handler_command_args = VecDeque::from( shell_words::split(&settings.handler_command).with_context(|| { format!( "Failed to shell-split handler command {:?}", &settings.handler_command ) - })?; + })?, + ); let handler_command_program = handler_command_args - .pop() + .pop_front() .ok_or(anyhow::Error::msg("empty handler command"))?; // Done Ok(App {