From patchwork Tue Dec 17 17:00:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Johannes_L=C3=B6thberg?= X-Patchwork-Id: 1414 X-Patchwork-Delegate: polycitizen@gmail.com Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 94BC615B3877E for ; Tue, 17 Dec 2019 17:00:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DMARC_POLICY_NONE=0.01 autolearn=ham autolearn_force=no version=3.4.3 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Tue, 17 Dec 2019 17:00:23 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 1CBFF17495EB58; Tue, 17 Dec 2019 17:00:19 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id CF96017495EB54; Tue, 17 Dec 2019 17:00:18 +0000 (UTC) Authentication-Results: orion.archlinux.org; dkim=pass (1024-bit key) header.d=kyriasis.com header.i=@kyriasis.com header.b=fSDUm340 Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id B262A2B837; Tue, 17 Dec 2019 17:00:18 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=pass (1024-bit key) header.d=kyriasis.com header.i=@kyriasis.com header.b=fSDUm340 Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id D5C422B789 for ; Tue, 17 Dec 2019 17:00:14 +0000 (UTC) Received: from theos.kyriasis.com (theos.kyriasis.com [IPv6:2a01:7e00:e000:136::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Tue, 17 Dec 2019 17:00:14 +0000 (UTC) Received: from theos.kyriasis.com (localhost [127.0.0.1]) by theos.kyriasis.com (OpenSMTPD) with ESMTP id 2222b1c8; Tue, 17 Dec 2019 17:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=kyriasis.com; h=from:to:cc :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=theos; bh=v1wNlmaifI9xYd2l0tvIGhLt 4G4=; b=fSDUm340np7JqodWFBmxL9Tq2oKpe2RNhegQuSWuwJ0I1l6A8k2Fkxrs zigspAgJwE4rFuPK34h+zLU0Cz05gcrebBoiwXePQXrFphz0kTpGdRWTvKFFTgQM 6InCFTeblIT6YQLmRXwu+m4tYTlu2zN6ndmaD2eBE5ObEA4N78c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=kyriasis.com; h=from:to:cc :subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=theos; b=OiY9j0XuNZOwSVk09a mP4g1csmAVP9MC2kOcaFy/bVVNSDdaB0YhhKH+3rHr47Al/4YCD0sgpWTNMt/ZZv BtS6gm/Z9R8CXXD+reTk9IdD68LpYtUTre/n2Ua6rzPIO3Zxm0g2K9HRs3UM2TU3 jG0m9x+87tQhTO4MSk6avpZvk= Received: from hydrogen.kyriasis.com (h-52-10.A572.priv.bahnhof.se [158.174.52.10]) by theos.kyriasis.com (OpenSMTPD) with ESMTPSA id 5c69b668 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) auth=yes user=kyrias; Tue, 17 Dec 2019 17:00:13 +0000 (UTC) From: =?utf-8?q?Johannes_L=C3=B6thberg?= To: pacman-contrib@lists.archlinux.org Subject: [PATCH] rankmirrors: Fix fragile and currently broken argparse shifting Date: Tue, 17 Dec 2019 18:00:02 +0100 Message-Id: <20191217170002.107841-1-johannes@kyriasis.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Johannes_L=C3=B6thberg?= Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Fixes FS#61923. Signed-off-by: Johannes Löthberg --- src/rankmirrors.sh.in | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rankmirrors.sh.in b/src/rankmirrors.sh.in index 08f7e28..7b78f37 100644 --- a/src/rankmirrors.sh.in +++ b/src/rankmirrors.sh.in @@ -154,33 +154,36 @@ while [[ $1 ]]; do STDIN=1 shift else - snum=1 for ((i=1 ; i<${#1}; i++)); do case ${1:$i:1} in h) usage ;; m) [[ $2 ]] || err "Must specify number."; MAX_TIME="$2" - shift 2;; + shift + ;; t) TIMESONLY=1 ;; v) VERBOSE=1 ;; u) CHECKURL=1; [[ $2 ]] || err "Must specify URL."; URL="$2"; - snum=2;; + shift + ;; r) [[ $2 ]] || err "Must specify repository name."; TARGETREPO="$2"; - snum=2;; + shift + ;; n) [[ $2 ]] || err "Must specify number."; NUM="$2"; - snum=2;; + shift + ;; *) err "'$1' is an invalid argument." ;; esac done - shift $snum + shift fi elif [[ -f $1 ]]; then FILE="1"