about summary refs log blame commit diff stats
path: root/modules/home/conf/lf/commands/scripts/unarchive.sh
blob: d4835f6bb149ab10ffff40876797d240272b767d (plain) (tree)
1
2
3
4
5
                    
 
                             
                                                   
 







                           

                                                 
















                                                           
            
#! /usr/bin/env dash

# shellcheck source=/dev/null
SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH

# shellcheck disable=SC2269
f="$f"
# shellcheck disable=SC2269
fx="$fx"
# shellcheck disable=SC2269
fs="$fs"
# shellcheck disable=SC2269
id="$id"

# extract the current file with the right command
# (xkcd link: https://xkcd.com/1168/)
set -f

unarchive() {
    case "$1" in
    *.tar.bz | *.tar.bz2 | *.tbz | *.tbz2) tar xjvf "$1" ;;
    *.tar.gz | *.tgz) tar xzvf "$1" ;;
    *.tar.xz | *.txz) tar xJvf "$1" ;;
    *.zip) unzip "$1" ;;
    *.rar)
        die "rar is a unfree format!"
        ;;
    *.7z) 7z x "$1" ;;
    *) die "Unsupported format" ;;
    esac
}

while read -r file; do
    unarchive "$file"
done <"$fx"
# vim: ft=sh