diff --git a/distrobox-enter b/distrobox-enter index 33f27ecf85..ab7d22966c 100755 --- a/distrobox-enter +++ b/distrobox-enter @@ -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. diff --git a/distrobox-rm b/distrobox-rm index b8ed16066b..616dfbba3e 100755 --- a/distrobox-rm +++ b/distrobox-rm @@ -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 ] &&