From 6345cbdb09eda657ca41524daaa80ca38032a94a Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Tue, 30 May 2023 14:55:47 +0200 Subject: [PATCH] xrestricted: add --yes flag for non-interactive use --- void/xrestricted | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/void/xrestricted b/void/xrestricted index 7357ece..6197f51 100755 --- a/void/xrestricted +++ b/void/xrestricted @@ -20,7 +20,9 @@ if [[ ! -d $PACKAGES_DIR ]]; then exit 1 fi -zparseopts -D -E h=help -help=help j:=jobs -jobs:=jobs b:=branch -branch:=branch +zparseopts -D -E h=help -help=help j:=jobs -jobs:=jobs b:=branch -branch:=branch y=yes -yes=yes + +if [[ $yes ]]; then echo "auto mode: $yes"; fi if [[ $help ]]; then <<-HELP @@ -70,7 +72,7 @@ install_restricted() { else echo "Package already built for version $2 ($existing), installing..." fi - xi $1 + xi $yes $1 } case $1 in @@ -99,8 +101,8 @@ case $1 in fi awk '{ printf "\x1b[34m%s\x1b[0m: %s → \x1b[92m%s\x1b[0m\n", $1, $2, $3 }' <<<"$possible_updates" - printf "Run updates? [y/N] " - if read -q; then + [[ -z $yes ]] && printf "Run updates? [y/N] " + if [[ $yes ]] || read -q; then echo for pkg ver in $(cut -d' ' -f 1,3 <<<"$possible_updates"); do install_restricted $pkg $ver