Skip to content

Commit

Permalink
Merge pull request #78 from WagnerPMC/master
Browse files Browse the repository at this point in the history
Fixing work of the WAIT_COMMAND environment variable
  • Loading branch information
ufoscout authored Sep 27, 2023
2 parents 48b2683 + f9ea0b8 commit 32dce8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

15 changes: 6 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ pub fn parse_command<S: Into<String>>(
if command_string.is_empty() {
return Ok(None);
}
let argv = shell_words::split(&command_string)?;
let mut argv = shell_words::split(&command_string)?;
Ok(Some((
Command {
program: argv[0].clone(),
program: argv.remove(0),
argv,
},
command_string,
Expand Down Expand Up @@ -308,15 +308,15 @@ mod test {
let (command, command_string) = parse_command("ls".to_string()).unwrap().unwrap();
assert_eq!("ls", command_string);
assert_eq!("ls", command.program);
assert_eq!(vec!["ls"], command.argv);
assert_eq!(Vec::<String>::new(), command.argv);
}

#[test]
fn parse_command_handles_commands_with_args() {
let (command, command_string) = parse_command("ls -al".to_string()).unwrap().unwrap();
assert_eq!("ls -al", command_string);
assert_eq!("ls", command.program);
assert_eq!(vec!["ls", "-al"], command.argv);
assert_eq!(vec!["-al"], command.argv);
}

#[test]
Expand All @@ -326,7 +326,7 @@ mod test {
.unwrap();
assert_eq!("hello world", command_string);
assert_eq!("hello", command.program);
assert_eq!(vec!["hello", "world"], command.argv);
assert_eq!(vec!["world"], command.argv);
}

#[test]
Expand All @@ -337,9 +337,6 @@ mod test {
.unwrap();
assert_eq!("find . -type \"f\" -name '*.rs'", command_string);
assert_eq!("find", command.program);
assert_eq!(
vec!["find", ".", "-type", "f", "-name", "*.rs"],
command.argv
);
assert_eq!(vec![".", "-type", "f", "-name", "*.rs"], command.argv);
}
}

0 comments on commit 32dce8c

Please sign in to comment.