Update checkdeps

This commit is contained in:
clsty
2025-10-30 12:33:34 +08:00
parent 8b25e2b037
commit f324310355
2 changed files with 10 additions and 23 deletions
+1 -1
View File
@@ -69,10 +69,10 @@ function pause(){
fi fi
} }
function remove_bashcomments_emptylines(){ function remove_bashcomments_emptylines(){
mkdir -p "$(dirname "$2")"
echo "pwd=$(pwd)" echo "pwd=$(pwd)"
echo "input=$1" echo "input=$1"
echo "output=$2" echo "output=$2"
mkdir -p "$(dirname "$2")"
cat "$1" | sed -e 's/#.*//' -e '/^[[:space:]]*$/d' > "$2" cat "$1" | sed -e 's/#.*//' -e '/^[[:space:]]*$/d' > "$2"
} }
function prevent_sudo_or_root(){ function prevent_sudo_or_root(){
+9 -22
View File
@@ -1,20 +1,19 @@
# Handle args for subcmd: exp-uninstall # Handle args for subcmd: checkdeps
# shellcheck shell=bash # shellcheck shell=bash
showhelp(){ showhelp(){
echo -e "Syntax: $0 checkdeps [OPTIONS]... echo -e "Syntax: $0 checkdeps [OPTIONS] <LIST_FILE_PATH>...
Experimental unintallation. Check whether pkgs listed in <LIST_FILE_PATH> exist in AUR or repos of Arch.
Options: Options:
-h, --help Show this help message -h, --help Show this help message
--file A file in plain text containing package names
" "
} }
# `man getopt` to see more # `man getopt` to see more
para=$(getopt \ para=$(getopt \
-o h \ -o h \
-l help,file: \ -l help \
-n "$0" -- "$@") -n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1 [ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
##################################################################################### #####################################################################################
@@ -28,21 +27,9 @@ while true ; do
*) shift ;; *) shift ;;
esac esac
done done
#####################################################################################
## getopt Phase 2
eval set -- "$para" if [[ -f "$1" ]]; then
while true ; do echo "Using list file \"$1\".";LIST_FILE_PATH="$1";shift 2
case "$1" in else
## Ones with parameter echo "Wrong path of list file.";exit 1
--file) fi
if [[ -f "$2" ]];
then echo "Using list file \"$2\".";LIST_FILE_PATH="$2";shift 2
else echo "Wrong argument for $1.";exit 1
fi;;
## Ending
--) break ;;
*) echo -e "$0: Wrong parameters.";exit 1;;
esac
done