Skip to content

Commit ceea889

Browse files
committed
penguin: check arg count before chekcing for shell arg
1 parent dd8f041 commit ceea889

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

penguin

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ penguin_run() {
354354
fi
355355

356356
# Similarly if we are running a shell in the container, start it if it's not already running, otherwise exec into that container
357-
if [[ "${cmd[0]}" == "shell" ]]; then
357+
if [[ ${#cmd[@]} -gt 0 && "${cmd[0]}" == "shell" ]]; then
358358
if [[ -n "$container_name" ]] && docker ps --format '{{.Names}}' | grep -q "^$container_name$"; then
359359
docker_cmd=("docker" "exec" "-it" "-w" "/workspace" "${container_name}" "bash")
360360
"${docker_cmd[@]}"
@@ -502,7 +502,7 @@ penguin_run() {
502502
done
503503

504504
# NEW: Default to current directory if running 'shell' with no path args
505-
if [ -z "$host_workspace_dir" ] && [[ "${cmd[0]}" == "shell" ]]; then
505+
if [[ ${#cmd[@]} -gt 0 && -z "$host_workspace_dir" && "${cmd[0]}" == "shell" ]]; then
506506
host_workspace_dir=$(pwd)
507507
# We append "." to the arguments passed to the container.
508508
# Since we effectively map cwd -> /workspace and set -w /workspace,
@@ -531,7 +531,7 @@ penguin_run() {
531531
fi
532532

533533
# NEW: Force working directory to /workspace if running shell
534-
if [[ "${cmd[0]}" == "shell" ]]; then
534+
if [[ ${#cmd[@]} -gt 0 && "${cmd[0]}" == "shell" ]]; then
535535
docker_cmd+=("-w" "/workspace")
536536
fi
537537

0 commit comments

Comments
 (0)