Skip to content

Commit

Permalink
enter: fix handle containers that have environment variables shorter …
Browse files Browse the repository at this point in the history
…than 5 (#1545)
  • Loading branch information
senioroman4uk authored Oct 10, 2024
1 parent 9a58610 commit 7fc534b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions distrobox-enter
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,8 @@ container_status="unknown"
eval "$(${container_manager} inspect --type container --format \
'container_status={{.State.Status}};
unshare_groups={{ index .Config.Labels "distrobox.unshare_groups" }};
{{range .Config.Env}}{{if slice . 0 5 | eq "HOME="}}container_home={{slice . 5 | printf "%q"}};{{end}}{{end}}
{{range .Config.Env}}{{if slice . 0 5 | eq "PATH="}}container_path={{slice . 5 | printf "%q"}}{{end}}{{end}}' \
{{range .Config.Env}}{{if and (ge (len .) 5) (eq (slice . 0 5) "HOME=")}}container_home={{slice . 5 | printf "%q"}}{{end}}{{end}};
{{range .Config.Env}}{{if and (ge (len .) 5) (eq (slice . 0 5) "PATH=")}}container_path={{slice . 5 | printf "%q"}}{{end}}{{end}}' \
"${container_name}")"

# dry run mode, just generate the command and print it. No execution.
Expand Down
2 changes: 1 addition & 1 deletion distrobox-rm
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ delete_container()
# Retrieve container's HOME, and check if it's different from host's one. In
# this case we prompt for deletion of the custom home.
container_home=$(${container_manager} inspect --type container --format \
'{{range .Config.Env}}{{if slice . 0 5 | eq "HOME="}}{{slice . 5}}{{end}}{{end}}' "${container_name}")
'{{range .Config.Env}}{{if and (ge (len .) 5) (eq (slice . 0 5) "HOME=")}}{{slice . 5 | printf "%q"}}{{end}}{{end}}' "${container_name}")
# Prompt for confirmation
if [ "${container_home}" != "${HOME}" ]; then
if [ "${non_interactive}" -eq 0 ] &&
Expand Down

0 comments on commit 7fc534b

Please sign in to comment.