From dce5146491b2f72d230ee9e362da991b91fca915 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 6 Dec 2024 01:24:16 +0300 Subject: [PATCH 1/2] Improve options parsing --- SOURCES/rpmbuilder | 13 ++++++------- SOURCES/rpmunbuilder | 14 +++++++------- rpmbuilder.spec | 5 ++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/SOURCES/rpmbuilder b/SOURCES/rpmbuilder index de39e4e..da5cbe4 100755 --- a/SOURCES/rpmbuilder +++ b/SOURCES/rpmbuilder @@ -13,7 +13,7 @@ fi APP="RPMBuilder" # Utility version (String) -VER="3.4.1" +VER="3.4.2" # Utility description (String) DESC="RPM package build helper" @@ -612,7 +612,7 @@ if [[ "$*" =~ "--tmux-worker" ]] ; then unset remote parallel fi -## OPTIONS PARSING 5 ################################################################### +## OPTIONS PARSING 6 ########################################################### if [[ $# -eq 0 ]] ; then main @@ -621,7 +621,7 @@ fi unset opt optn optm optv optt optk -optv="$*" ; optt="" +optv="$*" ; optt=() while [[ -n "$1" ]] ; do if [[ "$1" =~ \ && -n "$optn" ]] ; then @@ -711,8 +711,7 @@ while [[ -n "$1" ]] ; do fi fi - optt="$optt $1" ; shift - + optt+=("$1") ; shift done [[ -n "$optn" ]] && declare "$optn=true" @@ -720,6 +719,6 @@ done unset opt optn optm optk # shellcheck disable=SC2015,SC2086 -[[ -n "$KEEP_OPTS" ]] && main $optv || main ${optt:1} +[[ -n "$KEEP_OPTS" ]] && main $optv || main "${optt[@]}" -######################################################################################## +################################################################################ diff --git a/SOURCES/rpmunbuilder b/SOURCES/rpmunbuilder index ac57c4d..176de15 100755 --- a/SOURCES/rpmunbuilder +++ b/SOURCES/rpmunbuilder @@ -13,7 +13,7 @@ fi APP="RPMUnbuilder" # Utility version (String) -VER="1.3.0" +VER="1.3.1" ################################################################################ @@ -322,15 +322,16 @@ about() { show "Apache License, Version 2.0 " $DARK } -## OPTIONS PARSING 5 ################################################################### +## OPTIONS PARSING 6 ########################################################### if [[ $# -eq 0 ]] ; then main + exit $? fi unset opt optn optm optv optt optk -optv="$*" ; optt="" +optv="$*" ; optt=() while [[ -n "$1" ]] ; do if [[ "$1" =~ \ && -n "$optn" ]] ; then @@ -420,8 +421,7 @@ while [[ -n "$1" ]] ; do fi fi - optt="$optt $1" ; shift - + optt+=("$1") ; shift done [[ -n "$optn" ]] && declare "$optn=true" @@ -429,6 +429,6 @@ done unset opt optn optm optk # shellcheck disable=SC2015,SC2086 -[[ -n "$KEEP_OPTS" ]] && main $optv || main ${optt:1} +[[ -n "$KEEP_OPTS" ]] && main $optv || main "${optt[@]}" -######################################################################################## +################################################################################ diff --git a/rpmbuilder.spec b/rpmbuilder.spec index f18585a..e5bffc5 100644 --- a/rpmbuilder.spec +++ b/rpmbuilder.spec @@ -6,7 +6,7 @@ Summary: RPM package build helper Name: rpmbuilder -Version: 3.4.1 +Version: 3.4.2 Release: 0%{?dist} License: Apache License, Version 2.0 Group: Development/Tools @@ -58,6 +58,9 @@ install -pm 644 libexec/* %{buildroot}%{_libexecdir}/%{name}/ ################################################################################ %changelog +* Fri Dec 06 2024 Anton Novojilov - 3.4.2-0 +- Improved options parsing + * Wed Sep 11 2024 Anton Novojilov - 3.4.1-0 - Improved spec validation From eabcfba367106fa4c4387d8d3b1f7884c4f46461 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 6 Dec 2024 01:27:39 +0300 Subject: [PATCH 2/2] Code refactoring --- SOURCES/rpmbuilder | 4 ++-- SOURCES/rpmunbuilder | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/SOURCES/rpmbuilder b/SOURCES/rpmbuilder index da5cbe4..cd8e58c 100755 --- a/SOURCES/rpmbuilder +++ b/SOURCES/rpmbuilder @@ -272,8 +272,9 @@ main() { fi require "build" - startBuild "$@" + + exit $? } # Load libexec script @@ -616,7 +617,6 @@ fi if [[ $# -eq 0 ]] ; then main - exit $? fi unset opt optn optm optv optt optk diff --git a/SOURCES/rpmunbuilder b/SOURCES/rpmunbuilder index 176de15..90f1c1c 100755 --- a/SOURCES/rpmunbuilder +++ b/SOURCES/rpmunbuilder @@ -326,7 +326,6 @@ about() { if [[ $# -eq 0 ]] ; then main - exit $? fi unset opt optn optm optv optt optk