Skip to content

Commit cd19d08

Browse files
author
Max Dymond
authored
Merge pull request #302 from Metaswitch/issue/62/fixshells
Use shell_words to split the outer shell so that more complex outer shells can be used.
2 parents 18d159a + ec5aaed commit cd19d08

5 files changed

Lines changed: 22 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Status: Available for use
1616
### Added
1717

1818
### Fixed
19+
- #62: Use shell_words to split the outer shell so that more complex outer shells can be used.
1920

2021
## [1.2.0] - 2023-07-07
2122

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ thiserror = "1.0.40"
3131
tera = "1"
3232
serde_json = "1.0.100"
3333
toml = "0.7.6"
34+
shell-words = "1.1.0"
3435

3536
[dev-dependencies]
3637
tempfile = "3.6.0"

src/command.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ impl Drop for DaemonHandle {
4040
}
4141

4242
impl DockerCommandBuilder {
43-
pub fn run(&self, command: &[&str]) -> Result<(), Error> {
44-
debug!(
45-
"Spawning docker command with configuration: {:?} args: {:?}",
46-
self, command
47-
);
43+
pub fn run<I, S>(&self, command: I) -> Result<(), Error>
44+
where
45+
I: IntoIterator<Item = S> + std::fmt::Debug,
46+
S: AsRef<OsStr>,
47+
{
48+
debug!("Spawning docker command with configuration: {self:?}");
49+
debug!("- and args: {command:?}");
4850

4951
let mut command = Command::new("docker")
5052
.args(self.base_args())

src/interpret.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ pub(crate) fn run_floki_container(
5353
None
5454
};
5555

56+
// Calculate the outer shell command.
5657
let subshell_command = subshell_command(&spec.init, inner_command);
57-
cmd.run(&[spec.shell.outer_shell(), "-c", &subshell_command])
58+
let mut outer_shell_cmd = shell_words::split(spec.shell.outer_shell())?;
59+
outer_shell_cmd.push("-c".to_string());
60+
outer_shell_cmd.push(subshell_command);
61+
62+
cmd.run(outer_shell_cmd)
5863
}
5964

6065
pub(crate) fn command_in_shell(shell: &str, command: &[String]) -> String {

0 commit comments

Comments
 (0)