From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 56B3013888F for ; Fri, 16 Oct 2015 10:12:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8F36021C007; Fri, 16 Oct 2015 10:12:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E99E721C004 for ; Fri, 16 Oct 2015 10:12:27 +0000 (UTC) Received: from pomiot.local (77-254-165-0.adsl.inetia.pl [77.254.165.0]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 6F337340961; Fri, 16 Oct 2015 10:12:26 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH 2/3] eapply: Update parameter splitting to match the spec Date: Fri, 16 Oct 2015 12:12:15 +0200 Message-Id: <1444990336-16542-3-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1444990336-16542-1-git-send-email-mgorny@gentoo.org> References: <1444990336-16542-1-git-send-email-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 05689657-e508-4a80-8365-5cc1fe6d54b4 X-Archives-Hash: abc824ff55d9bb1b2159381f2d1822bb --- bin/phase-helpers.sh | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 0c25ffe..5be71fa 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -997,18 +997,42 @@ if ___eapi_has_eapply; then fi } - local f patch_options=() failed started_applying options_terminated - for f; do - if [[ ${f} == -* && -z ${options_terminated} ]]; then - if [[ -n ${started_applying} ]]; then - die "eapply: options need to be specified before files" + local patch_options=() files=() + local i found_doublehyphen + # first, try to split on -- + for (( i = 1; i <= ${#@}; ++i )); do + if [[ ${@:i:1} == -- ]]; then + patch_options=( "${@:1:i-1}" ) + files=( "${@:i+1}" ) + found_doublehyphen=1 + break + fi + done + + # then, try to split on first non-option + if [[ -z ${found_doublehyphen} ]]; then + for (( i = 1; i <= ${#@}; ++i )); do + if [[ ${@:i:1} != -* ]]; then + patch_options=( "${@:1:i-1}" ) + files=( "${@:i+1}" ) + break fi - if [[ ${f} == -- ]]; then - options_terminated=1 - else - patch_options+=( ${f} ) + done + + # ensure that no options were interspersed with files + for i in "${files[@]}"; then + if [[ ${i} == -* ]]; then + die "eapply: all options must be passed before non-options" fi - elif [[ -d ${f} ]]; then + fi + fi + + if [[ -z ${files[@]} ]]; then + die "eapply: no files specified" + fi + + for i in "${files[@]}"; do + if [[ -d ${f} ]]; then _eapply_get_files() { local LC_ALL=POSIX local prev_shopt=$(shopt -p nullglob) -- 2.6.1