diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org> | 2011-05-01 16:50:30 +0200 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org> | 2011-05-01 16:50:30 +0200 |
commit | 693681562c7795473efd0caaa05b8d52b28f75db (patch) | |
tree | 6e5f9b15a2e1256b9eb2a03a57830e98f07c7f06 /bin/ebuild.sh | |
parent | 92d5eba065f12c38cdbb2e24e13ee3b123f92245 (diff) | |
download | portage-693681562c7795473efd0caaa05b8d52b28f75db.tar.gz portage-693681562c7795473efd0caaa05b8d52b28f75db.tar.bz2 portage-693681562c7795473efd0caaa05b8d52b28f75db.zip |
Support multiple arguments in set_unless_changed() and unset_unless_changed().
Use VARIABLE=VALUE syntax for arguments of set_unless_changed().
Diffstat (limited to 'bin/ebuild.sh')
-rwxr-xr-x | bin/ebuild.sh | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh index e652cb55b..6593755cd 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1639,32 +1639,39 @@ _ebuild_phase_funcs() { esac } -# Set given variable unless this variable has been already set (e.g. during emerge -# invocation) to a value different than value set in make.conf. +# Set given variables unless these variable have been already set (e.g. during emerge +# invocation) to values different than values set in make.conf. set_unless_changed() { - if [[ $# -ne 2 ]]; then - die "${FUNCNAME}() requires 2 arguments: VARIABLE VALUE" + if [[ $# -lt 1 ]]; then + die "${FUNCNAME}() requires at least 1 argument: VARIABLE=VALUE" fi - local variable="$1" value="$2" - - if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then - eval "${variable}=\"${value}\"" - fi + local argument value variable + for argument in "$@"; do + if [[ ${argument} != *=* ]]; then + die "${FUNCNAME}(): Argument '${argument}' has incorrect syntax" + fi + variable="${argument%%=*}" + value="${argument#*=}" + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then + eval "${variable}=\"${value}\"" + fi + done } -# Unset given variable unless this variable has been set (e.g. during emerge -# invocation) to a value different than value set in make.conf. +# Unset given variables unless these variable have been set (e.g. during emerge +# invocation) to values different than values set in make.conf. unset_unless_changed() { - if [[ $# -ne 1 ]]; then - die "${FUNCNAME}() requires 1 argument: VARIABLE" + if [[ $# -lt 1 ]]; then + die "${FUNCNAME}() requires at least 1 argument: VARIABLE" fi - local variable="$1" - - if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then - unset ${variable} - fi + local variable + for variable in "$@"; do + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then + unset ${variable} + fi + done } PORTAGE_BASHRCS_SOURCED=0 |