add appimage fetch option and cleaner zzexe

This commit is contained in:
Phantop 2023-01-23 22:35:47 -05:00
parent 4dd8196538
commit f3efc1ebb7
1 changed files with 9 additions and 7 deletions

View File

@ -29,8 +29,8 @@ unappimage() {
} }
zzexe() { zzexe() {
[ "$1" = "-p" ] && p="$2" && shift 2 # save prefix if present [ "$1" = "-p" ] && p="$2" && shift # save prefix if present
tmp=$(mktemp) # make tmp file to avoid io operations shift; tmp=$(mktemp) # make tmp file to avoid io operations
printfunc zzexe_header | sed -e "2s/);$/${1##*[./]})/" -e "7s/^/$p /" > "$tmp" printfunc zzexe_header | sed -e "2s/);$/${1##*[./]})/" -e "7s/^/$p /" > "$tmp"
zstdmt -cq19 "$@" >> "$tmp" zstdmt -cq19 "$@" >> "$tmp"
mv "$tmp" "$1" mv "$tmp" "$1"
@ -65,19 +65,20 @@ case "$1" in
mv "$tmp" "$2" mv "$tmp" "$2"
chmod +x "$2" chmod +x "$2"
exit ;; exit ;;
-p ) --fetch )
zzexe "$@" ;; FETCH=1
-z) shift ;;
shift -p | -z)
zzexe "$@" ;; zzexe "$@" ;;
--version | -v ) --version | -v )
tput setaf 2; echo appdwarf 2023.01.14 tput setaf 2; echo appdwarf 2023.01.23
tput setaf 6; echo Built by July 🏳️‍🌈; exit ;; tput setaf 6; echo Built by July 🏳️‍🌈; exit ;;
-* | '' ) -* | '' )
echo "Usage: appdwarf [option] [APP/FILE/FOLDER/URL] [compression options]" echo "Usage: appdwarf [option] [APP/FILE/FOLDER/URL] [compression options]"
echo " -a [file] Write example AppRun to file and exit" echo " -a [file] Write example AppRun to file and exit"
echo " -b [file] Write example AppRun with bin subdir to file and exit" echo " -b [file] Write example AppRun with bin subdir to file and exit"
echo " -d [file] Decompress an appdwarf image or zzexe'd file" echo " -d [file] Decompress an appdwarf image or zzexe'd file"
echo " --fetch Exit after fetching a remote AppImage, if applicable"
echo echo
echo " -p [prefix] zzexe a file with prefix" echo " -p [prefix] zzexe a file with prefix"
echo " -z zzexe a file" echo " -z zzexe a file"
@ -112,6 +113,7 @@ if [ ! -d "$1" ]; then # directory doesn't exist, see if this is an appimage
if aria2c -x16 -s16 "$1" -o "$app" || wget "$1" -O "$app"; then if aria2c -x16 -s16 "$1" -o "$app" || wget "$1" -O "$app"; then
shift shift
set -- "$app" "$@" set -- "$app" "$@"
test $FETCH && chmod +x "$1" && exit
else else
tput setaf 1; echo "No valid remote or local input found. Exiting..." >&2 tput setaf 1; echo "No valid remote or local input found. Exiting..." >&2
rm -f "$app"; exit 1 rm -f "$app"; exit 1