Skip to content

Commit

Permalink
Merge pull request #48 from containers/entrypoint-fix
Browse files Browse the repository at this point in the history
create: Allow empty strings anywhere in the container command
  • Loading branch information
albertofaria authored Apr 16, 2024
2 parents 1efbd7d + 565ec60 commit 8b4dcf0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/commands/create/custom_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@ impl CustomOptions {
.args()
.iter()
.flatten()
.filter(|a| !a.trim().is_empty())
.collect();

if let Some(&first_arg) = args.first() {
if first_arg.trim().is_empty() || first_arg == "no-entrypoint" {
if first_arg == "no-entrypoint" {
args.remove(0);
}
}

// TODO: We currently assume that no entrypoint is given (either by being set by in the
// container image or through --entrypoint). Must somehow find whether the first arg is the
// entrypoint and ignore it in that case.
if let Some(&first_arg) = args.first() {
ensure!(
first_arg.starts_with("-"),
"unexpected entrypoint '{first_arg}' found; use an image without an entrypoint or with entrypoint \"no-entrypoint\", and/or pass in an empty \"\" entrypoint on the command line"
);
}

let mut options = CustomOptions::parse_from(
iter::once(&"podman run [<podman-opts>] <image>".to_string()).chain(args),
);
Expand Down

0 comments on commit 8b4dcf0

Please sign in to comment.