Diff
1diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
2index b7a823c9fdb77d73ead567d526609835de520ce5..513950f33b5df018c2d30ea4f87060b5bd0310d4 100644
3--- a/plugins/extract/extract.plugin.zsh
4+++ b/plugins/extract/extract.plugin.zsh
5@@ -64,7 +64,7 @@ EOF
6 (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;;
7 (*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
8 (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
9- (*.gz) (( $+commands[pigz] )) && pigz -dk "$full_path" || gunzip -k "$full_path" ;;
10+ (*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
11 (*.bz2) bunzip2 "$full_path" ;;
12 (*.xz) unxz "$full_path" ;;
13 (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
14@@ -106,19 +106,19 @@ EOF
15 # - Y2: at most give 2 files
16 local -a content
17 content=("${extract_dir}"/*(DNY2))
18- if [[ ${#content} -eq 1 && -d "${content[1]}" ]]; then
19- # The extracted folder (${content[1]}) may have the same name as $extract_dir
20+ if [[ ${#content} -eq 1 && -e "${content[1]}" ]]; then
21+ # The extracted file/folder (${content[1]}) may have the same name as $extract_dir
22 # If so, we need to rename it to avoid conflicts in a 3-step process
23 #
24- # 1. Move and rename the extracted folder to a temporary random name
25+ # 1. Move and rename the extracted file/folder to a temporary random name
26 # 2. Delete the empty folder
27- # 3. Rename the extracted folder to the original name
28+ # 3. Rename the extracted file/folder to the original name
29 if [[ "${content[1]:t}" == "$extract_dir" ]]; then
30 # =(:) gives /tmp/zsh<random>, with :t it gives zsh<random>
31- local tmp_dir==(:); tmp_dir="${tmp_dir:t}"
32- command mv "${content[1]}" "$tmp_dir" \
33+ local tmp_name==(:); tmp_name="${tmp_name:t}"
34+ command mv "${content[1]}" "$tmp_name" \
35 && command rmdir "$extract_dir" \
36- && command mv "$tmp_dir" "$extract_dir"
37+ && command mv "$tmp_name" "$extract_dir"
38 # Otherwise, if the extracted folder name already exists in the current
39 # directory (because of a previous file / folder), keep the extract_dir
40 elif [[ ! -e "${content[1]:t}" ]]; then