Gentoo Archives: gentoo-commits

From: Arfrever Frehtes Taifersar Arahesis <arfrever@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: man/, bin/
Date: Sun, 01 May 2011 14:52:18
Message-Id: 693681562c7795473efd0caaa05b8d52b28f75db.arfrever@gentoo
1 commit: 693681562c7795473efd0caaa05b8d52b28f75db
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
3 AuthorDate: Sun May 1 14:50:30 2011 +0000
4 Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
5 CommitDate: Sun May 1 14:50:30 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=69368156
7
8 Support multiple arguments in set_unless_changed() and unset_unless_changed().
9 Use VARIABLE=VALUE syntax for arguments of set_unless_changed().
10
11 ---
12 bin/ebuild.sh | 43 +++++++++++++++++++++++++------------------
13 man/portage.5 | 4 ++--
14 2 files changed, 27 insertions(+), 20 deletions(-)
15
16 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
17 index e652cb5..6593755 100755
18 --- a/bin/ebuild.sh
19 +++ b/bin/ebuild.sh
20 @@ -1639,32 +1639,39 @@ _ebuild_phase_funcs() {
21 esac
22 }
23
24 -# Set given variable unless this variable has been already set (e.g. during emerge
25 -# invocation) to a value different than value set in make.conf.
26 +# Set given variables unless these variable have been already set (e.g. during emerge
27 +# invocation) to values different than values set in make.conf.
28 set_unless_changed() {
29 - if [[ $# -ne 2 ]]; then
30 - die "${FUNCNAME}() requires 2 arguments: VARIABLE VALUE"
31 + if [[ $# -lt 1 ]]; then
32 + die "${FUNCNAME}() requires at least 1 argument: VARIABLE=VALUE"
33 fi
34
35 - local variable="$1" value="$2"
36 -
37 - if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then
38 - eval "${variable}=\"${value}\""
39 - fi
40 + local argument value variable
41 + for argument in "$@"; do
42 + if [[ ${argument} != *=* ]]; then
43 + die "${FUNCNAME}(): Argument '${argument}' has incorrect syntax"
44 + fi
45 + variable="${argument%%=*}"
46 + value="${argument#*=}"
47 + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then
48 + eval "${variable}=\"${value}\""
49 + fi
50 + done
51 }
52
53 -# Unset given variable unless this variable has been set (e.g. during emerge
54 -# invocation) to a value different than value set in make.conf.
55 +# Unset given variables unless these variable have been set (e.g. during emerge
56 +# invocation) to values different than values set in make.conf.
57 unset_unless_changed() {
58 - if [[ $# -ne 1 ]]; then
59 - die "${FUNCNAME}() requires 1 argument: VARIABLE"
60 + if [[ $# -lt 1 ]]; then
61 + die "${FUNCNAME}() requires at least 1 argument: VARIABLE"
62 fi
63
64 - local variable="$1"
65 -
66 - if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then
67 - unset ${variable}
68 - fi
69 + local variable
70 + for variable in "$@"; do
71 + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then
72 + unset ${variable}
73 + fi
74 + done
75 }
76
77 PORTAGE_BASHRCS_SOURCED=0
78
79 diff --git a/man/portage.5 b/man/portage.5
80 index a210e8d..ece47e5 100644
81 --- a/man/portage.5
82 +++ b/man/portage.5
83 @@ -679,12 +679,12 @@ set_unless_changed and unset_unless_changed functions can be used to set or
84 unset given variables only if these variable have not been set to values
85 different than values set in make.conf. This functionality can be useful for
86 temporary overriding of these variables during emerge invocation. Variables
87 -set in the usual VARIABLE=VALUE style will unconditionally override variables
88 +set without using set_unless_changed will unconditionally override variables
89 set during emerge invocation.
90
91 .I Syntax:
92 .nf
93 -set_unless_changed VARIABLE VALUE
94 +set_unless_changed VARIABLE=VALUE
95 unset_unless_changed VALUE
96 .fi