Skip to content

Commit

Permalink
Seperates arguments with \0 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkar598 authored Nov 7, 2022
1 parent d9602ab commit 9046067
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ signal: (INT) signal to send

path: (B64_STR) Path of the executable

args: (B64_STR) Arguments to run the executable with
args: (B64_STR) Arguments to run the executable with. Arguments are seperated with \0

env: (B64_STR) Environment variables to pass to the executable in the following format: `VAR1=VAL1;VAR2=VAL2;`. Take care to escape `\;`, `\=` and `\\` properly.

Expand Down
5 changes: 3 additions & 2 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ pub fn process(
Err(e) => return Err(format!("Error decoding exec path: {}", e)),
};

let args = match decode(b_args) {
let raw_args = match decode(b_args) {
Ok(dec_vec) if dec_vec.is_empty() => String::new(),
Ok(dec_vec) => String::from_utf8(dec_vec).expect("Invalid UTF8 for exec args"),
Err(e) => return Err(format!("Error decoding exec args: {}", e)),
};
let args = raw_args.split('\0').collect::<Vec<&str>>();

let raw_env_vars = match decode(b_env_vars) {
Ok(dec_vec) if dec_vec.is_empty() => String::new(),
Expand Down Expand Up @@ -95,7 +96,7 @@ pub fn process(
let poll_data = poll_data_main.clone();

let mut proc = match Exec::cmd(process)
.arg(args)
.args(args.as_slice())
.env_extend(&env_vars)
.stdout(Redirection::Pipe)
.stderr(Redirection::Pipe)
Expand Down

0 comments on commit 9046067

Please sign in to comment.