From 378e4d61fb2943f3483b9f1a41acf512af124af4 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:04:12 -0700 Subject: [PATCH] Bug fix sgit It did not iterate over all globs because the condition of the loop was while [[ "$i" -le "$#" ]]; do but in the loop i was incremented but the num args left was decremented thus they went in opposite orders. Instead record how many globs are there first and check i against that. --- bin/sgit | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/sgit b/bin/sgit index cf8b12c1f..88e69f87a 100755 --- a/bin/sgit +++ b/bin/sgit @@ -16,7 +16,7 @@ # - Cody Boone Ferguson (@xexyl) # -export SGIT_VERSION="0.0.5-1 16-02-2023" # format: major.minor.patch-release DD-MM-YYYY +export SGIT_VERSION="0.0.6-1 17-03-2023" # format: major.minor.patch-release DD-MM-YYYY USAGE="usage: $(basename "$0") [-h] [-V] [-v level] [-x] [-I] [-o sed_options] [-s sed] [-e command] @@ -142,11 +142,14 @@ fi if [[ "$VERBOSITY" -gt 1 ]]; then echo "debug[2]: looping through all globs" 1>&2 fi + +GLOBS="$#" i=0 -while [[ "$i" -le "$#" ]]; do +while [[ "$i" -lt "$GLOBS" ]]; do if [[ "$VERBOSITY" -gt 1 ]]; then - echo "debug[2]: found glob: $1" 1>&2 + echo "debug[2]: found glob: $i" 1>&2 fi + if [[ "$VERBOSITY" -ge 1 ]]; then if [[ -z "$I_FLAG" ]]; then if [[ -n "$SED_OPTIONS" ]]; then @@ -178,4 +181,12 @@ while [[ "$i" -le "$#" ]]; do fi ((i++)) shift 1 + if [[ "$VERBOSITY" -gt 2 ]]; then + if [[ "$#" -eq 1 ]]; then + echo "debug[2]: $# remaining glob" 1>&2 + else + echo "debug[2]: $# remaining globs" 1>&2 + fi + fi + done