mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-08-07 06:08:39 +02:00
fix(extract): correct directory handling for extracted content
This commit is contained in:
parent
0b899f137b
commit
4d705c6cfd
1 changed files with 4 additions and 4 deletions
|
|
@ -157,7 +157,7 @@ EOF
|
||||||
# 1. Move and rename the extracted file/folder to a temporary random name
|
# 1. Move and rename the extracted file/folder to a temporary random name
|
||||||
# 2. Delete the empty folder
|
# 2. Delete the empty folder
|
||||||
# 3. Rename the extracted file/folder to the original name
|
# 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<random>, with :t it gives zsh<random>
|
# =(:) gives /tmp/zsh<random>, with :t it gives zsh<random>
|
||||||
local tmp_name==(:); tmp_name="${tmp_name:t}"
|
local tmp_name==(:); tmp_name="${tmp_name:t}"
|
||||||
command mv "${content[1]}" "$tmp_name" \
|
command mv "${content[1]}" "$tmp_name" \
|
||||||
|
|
@ -165,9 +165,9 @@ EOF
|
||||||
&& command mv "$tmp_name" "$extract_dir"
|
&& command mv "$tmp_name" "$extract_dir"
|
||||||
# Otherwise, if the extracted folder name already exists in the current
|
# Otherwise, if the extracted folder name already exists in the current
|
||||||
# directory (because of a previous file / folder), keep the extract_dir
|
# directory (because of a previous file / folder), keep the extract_dir
|
||||||
elif [[ ! -e "${content[1]:t}" ]]; then
|
elif [[ ! -e "${target_directory:-.}/${content[1]:t}" ]]; then
|
||||||
command mv "${content[1]}" . \
|
command mv -- "${content[1]}" "${target_directory:-.}/" \
|
||||||
&& command rmdir "$extract_dir"
|
&& command rmdir -- "$extract_dir"
|
||||||
fi
|
fi
|
||||||
elif [[ ${#content} -eq 0 ]]; then
|
elif [[ ${#content} -eq 0 ]]; then
|
||||||
command rmdir "$extract_dir"
|
command rmdir "$extract_dir"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue