From a4f08ad238dba23a68df2a89b8fd47b8a9d26b0e Mon Sep 17 00:00:00 2001 From: Filippo Bonazzi Date: Wed, 22 Feb 2023 10:16:28 +0100 Subject: [PATCH] feat(extract): support `obscpio` format (#11511) Co-authored-by: Carlo Sala --- plugins/extract/README.md | 15 ++++++++------- plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index f67b53618..ac4a8e197 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -1,10 +1,10 @@ # extract plugin -This plugin defines a function called `extract` that extracts the archive file -you pass it, and it supports a wide variety of archive filetypes. +This plugin defines a function called `extract` that extracts the archive file you pass it, and it supports a +wide variety of archive filetypes. -This way you don't have to know what specific command extracts a file, you just -do `extract ` and the function takes care of the rest. +This way you don't have to know what specific command extracts a file, you just do `extract ` and +the function takes care of the rest. To use it, add `extract` to the plugins array in your zshrc file: @@ -15,7 +15,7 @@ plugins=(... extract) ## Supported file extensions | Extension | Description | -|:------------------|:-------------------------------------| +| :---------------- | :----------------------------------- | | `7z` | 7zip file | | `Z` | Z archive (LZW) | | `apk` | Android app file | @@ -32,6 +32,7 @@ plugins=(... extract) | `lrz` | LRZ archive | | `lz4` | LZ4 archive | | `lzma` | LZMA archive | +| `obscpio` | cpio archive used on OBS | | `rar` | WinRAR archive | | `rpm` | RPM package | | `sublime-package` | Sublime Text package | @@ -57,5 +58,5 @@ plugins=(... extract) | `zst` | Zstandard file (zstd) | | `zpaq` | Zpaq file | -See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for -more information regarding archive formats. +See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information +regarding archive formats. diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 64678fede..56b17058f 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|obscpio|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 4c84ef883..7b7a2fa4f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -72,7 +72,7 @@ EOF builtin cd -q ..; command rm *.tar.* debian-binary ;; (*.zst) unzstd "$file" ;; (*.cab) cabextract -d "$extract_dir" "$file" ;; - (*.cpio) cpio -idmvF "$file" ;; + (*.cpio|*.obscpio) cpio -idmvF "$file" ;; (*.zpaq) zpaq x "$file" ;; (*) echo "extract: '$file' cannot be extracted" >&2