From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 2/3] eapply: Update parameter splitting to match the spec
Date: Fri, 16 Oct 2015 12:12:15 +0200 [thread overview]
Message-ID: <1444990336-16542-3-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1444990336-16542-1-git-send-email-mgorny@gentoo.org>
---
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
next prev parent reply other threads:[~2015-10-16 10:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 10:12 [gentoo-portage-dev] [PATCHES] EAPI 6 updates Michał Górny
2015-10-16 10:12 ` [gentoo-portage-dev] [PATCH 1/3] EAPI 6: make in_iuse fatal in global scope Michał Górny
2015-10-16 10:12 ` Michał Górny [this message]
2015-10-16 10:12 ` [gentoo-portage-dev] [PATCH 3/3] eapply: Update default patch arguments Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444990336-16542-3-git-send-email-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-portage-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox