From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-846039-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id A5CD11384B4 for <garchives@archives.gentoo.org>; Thu, 12 Nov 2015 19:32:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E747821C0AC; Thu, 12 Nov 2015 19:32:49 +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 7AA5A21C0AC for <gentoo-commits@lists.gentoo.org>; Thu, 12 Nov 2015 19:32:49 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 61EE33403A3 for <gentoo-commits@lists.gentoo.org>; Thu, 12 Nov 2015 19:32:48 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 86FAF1470 for <gentoo-commits@lists.gentoo.org>; Thu, 12 Nov 2015 19:32:46 +0000 (UTC) From: "Michał Górny" <mgorny@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" <mgorny@gentoo.org> Message-ID: <1447356757.e3386ff407d0e6df8e3bdc15ed42f9373b88cddb.mgorny@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/phase-helpers.sh X-VCS-Directories: bin/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: e3386ff407d0e6df8e3bdc15ed42f9373b88cddb X-VCS-Branch: master Date: Thu, 12 Nov 2015 19:32:46 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 9939c288-7fc8-43de-816a-5bb687327c66 X-Archives-Hash: e79072ff100b871906dc48463a3f543b commit: e3386ff407d0e6df8e3bdc15ed42f9373b88cddb Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Fri Oct 16 10:04:46 2015 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Thu Nov 12 19:32:37 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e3386ff4 eapply: Update parameter splitting to match the spec 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)