From 9c5ca97ecc9ff5b1dc47193f5a4fe8543e367996 Mon Sep 17 00:00:00 2001 From: layman Date: Wed, 31 Aug 2022 07:47:07 +0200 Subject: [PATCH] use loop for option handling --- gentooup.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/gentooup.sh b/gentooup.sh index 565d83c..4b41cff 100755 --- a/gentooup.sh +++ b/gentooup.sh @@ -39,15 +39,27 @@ if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then CHROOTED=1 fi -if [[ ${1} == "--no-sync" || ${2} == "--no-sync" ]] ; then - echo "not syncing" - SYNC_COMMAND="" -fi - -if [[ ${1} == "--full" || ${2} == "--full" ]] ; then - echo "Do a full upgrade including build dependencies" - PORTAGE_UPGRADE_OPTIONS+=("--with-bdeps=y") -fi +while [[ $# -gt 0 ]]; do + case $1 in + --no-sync) + echo "not syncing" + SYNC_COMMAND="" + shift + ;; + --full) + echo "Do a full upgrade including build dependencies" + PORTAGE_UPGRADE_OPTIONS+=("--with-bdeps=y") + shift + ;; + --*) + echo "Unknown option $1" + shift + ;; + *) + echo "Positional arguments aren't supported" + ;; + esac + done if [[ $CHROOTED == 1 ]] ; then SYNC_COMMAND="layman -S"