✨ Added first feature of xtract, .tgz format
This commit is contained in:
parent
10e9b16024
commit
be08bd6b01
1 changed files with 35 additions and 7 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
# Error handling
|
# Error handling
|
||||||
set -e
|
set -e
|
||||||
|
|
@ -11,13 +11,13 @@ txtred=${txtbld}$(tput setaf 1)
|
||||||
txtyellow=${txtbld}$(tput setaf 3)
|
txtyellow=${txtbld}$(tput setaf 3)
|
||||||
txtwhite=${txtbld}$(tput setaf 7)
|
txtwhite=${txtbld}$(tput setaf 7)
|
||||||
|
|
||||||
# Intro Prompt
|
|
||||||
echo "${txtgreen}xtract: a simple shell script for decompressing common file formats"
|
|
||||||
|
|
||||||
# Dependency check
|
# To be implemented:
|
||||||
# not to be used in actual program, encapsulate in function and use depending on which file is fed to xtract
|
# dependencies=("echo" "sed" "tar" "zip" "bzip2" "gzip" "gunzip" "pax" "7z" "ar" "cpio" "brotli" "lzip" "rzip" "xz" "zstd")
|
||||||
dependencies=("tar" "zip" "bzip2" "gzip" "gunzip" "pax" "7z" "ar" "cpio" "brotli" "lzip" "rzip" "xz" "zstd")
|
|
||||||
numdependencies=14
|
# Main Dependency check
|
||||||
|
dependencies=("echo" "sed" "tput")
|
||||||
|
numdependencies=3
|
||||||
missingdependencies=0
|
missingdependencies=0
|
||||||
for ((i = 0; i < numdependencies; i++)) ;
|
for ((i = 0; i < numdependencies; i++)) ;
|
||||||
do
|
do
|
||||||
|
|
@ -28,3 +28,31 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Intro Prompt
|
||||||
|
echo "${txtgreen}xtract: a simple shell script for decompressing common file formats"
|
||||||
|
|
||||||
|
# Reset output style
|
||||||
|
tput bold & tput setaf 7
|
||||||
|
|
||||||
|
# grabs the extension string
|
||||||
|
extension=$(echo "${1}" | sed 's/^[^\..:]*[\..]//')
|
||||||
|
|
||||||
|
if [ "${extension}" == "tgz" ] ; then
|
||||||
|
|
||||||
|
# Dependency check
|
||||||
|
dependencies=("echo" "tar" "gunzip")
|
||||||
|
numdependencies=3
|
||||||
|
missingdependencies=0
|
||||||
|
for ((i = 0; i < numdependencies; i++)) ;
|
||||||
|
do
|
||||||
|
if ! command -v "${dependencies[$i]}" &> /dev/null
|
||||||
|
then
|
||||||
|
echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}"
|
||||||
|
missingdependencies=$((missingdependencies+1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "${txtblue}decompressing .tgz...${txtgreen}"
|
||||||
|
tar zxvf "${1}" &> /dev/null
|
||||||
|
echo ".tgz decompression finished!${txtwhite}"
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue