From 4d705c6cfda6acb9a76e2bf730a68d313d22145d Mon Sep 17 00:00:00 2001 From: Dylan Roman Date: Fri, 29 May 2026 20:53:35 -0400 Subject: [PATCH] fix(extract): correct directory handling for extracted content --- plugins/extract/extract.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index cfca62251..8219f974e 100755 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -157,7 +157,7 @@ EOF # 1. Move and rename the extracted file/folder to a temporary random name # 2. Delete the empty folder # 3. Rename the extracted file/folder to the original name - if [[ "${content[1]:t}" == "$extract_dir" ]]; then + if [[ "${content[1]:t}" == "${extract_dir:t}" ]]; then # =(:) gives /tmp/zsh, with :t it gives zsh local tmp_name==(:); tmp_name="${tmp_name:t}" command mv "${content[1]}" "$tmp_name" \ @@ -165,9 +165,9 @@ EOF && command mv "$tmp_name" "$extract_dir" # Otherwise, if the extracted folder name already exists in the current # directory (because of a previous file / folder), keep the extract_dir - elif [[ ! -e "${content[1]:t}" ]]; then - command mv "${content[1]}" . \ - && command rmdir "$extract_dir" + elif [[ ! -e "${target_directory:-.}/${content[1]:t}" ]]; then + command mv -- "${content[1]}" "${target_directory:-.}/" \ + && command rmdir -- "$extract_dir" fi elif [[ ${#content} -eq 0 ]]; then command rmdir "$extract_dir"