92aed2e93624124182ba977a91efa5bbe1e76d5f

Author
Tanzim Hossain Romel <romel.rcs@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(extract): add unar as fallback for RAR extraction (#13472)

Add unar as a fallback when unrar is not available for extracting
RAR files. This addresses the issue where unrar has been removed
from Homebrew due to licensing issues.

The extraction now:
- Prefers unrar if available (backward compatible)
- Falls back to unar if unrar is not found
- Shows helpful error message if neither tool is installed

Diff

 1diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
 2index d8cbc8b945ef66c54f8c1127ad4fa3d7bfdb2793..aed77e7d7ffb57e51285f94f45d3035ca7b474bb 100644
 3--- a/plugins/extract/extract.plugin.zsh
 4+++ b/plugins/extract/extract.plugin.zsh
 5@@ -77,7 +77,15 @@ EOF
 6       (*.lzma) unlzma "$full_path" ;;
 7       (*.z) uncompress "$full_path" ;;
 8       (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
 9-      (*.rar) unrar x -ad "$full_path" ;;
10+      (*.rar)
11+        if (( $+commands[unrar] )); then
12+          unrar x -ad "$full_path"
13+        elif (( $+commands[unar] )); then
14+          unar -o . "$full_path"
15+        else
16+          echo "extract: cannot extract RAR files: install unrar or unar" >&2
17+          success=1
18+        fi ;;
19       (*.rpm)
20         rpm2cpio "$full_path" | cpio --quiet -id ;;
21       (*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;