/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Diff of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.373 Revision 1.376
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.373 2011/12/16 23:38:41 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.376 2011/12/17 06:13:50 vapier Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
135 # copy of "i" rather than the caller's copy. The __estack_xxx 135 # copy of "i" rather than the caller's copy. The __estack_xxx
136 # garbage is preferable to using $1/$2 everywhere as that is a 136 # garbage is preferable to using $1/$2 everywhere as that is a
137 # bit harder to read. 137 # bit harder to read.
138 local __estack_name="__ESTACK_$1__" ; shift 138 local __estack_name="__ESTACK_$1__" ; shift
139 local __estack_retvar=$1 ; shift 139 local __estack_retvar=$1 ; shift
140 eval local __estack_i=\${#${__estack_name}[@]} 140 eval local __estack_i=\${#${__estack_name}\[@\]}
141 # Don't warn -- let the caller interpret this as a failure 141 # Don't warn -- let the caller interpret this as a failure
142 # or as normal behavior (akin to `shift`) 142 # or as normal behavior (akin to `shift`)
143 [[ $(( --__estack_i )) -eq -1 ]] && return 1 143 [[ $(( --__estack_i )) -eq -1 ]] && return 1
144 144
145 if [[ -n ${__estack_retvar} ]] ; then 145 if [[ -n ${__estack_retvar} ]] ; then
146 eval ${__estack_retvar}=\"\${${__estack_name}[${__estack_i}]}\" 146 eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\"
147 fi 147 fi
148 eval unset ${__estack_name}[${__estack_i}] 148 eval unset ${__estack_name}\[${__estack_i}\]
149} 149}
150 150
151# @FUNCTION: eshopts_push 151# @FUNCTION: eshopts_push
152# @USAGE: [options to `set` or `shopt`] 152# @USAGE: [options to `set` or `shopt`]
153# @DESCRIPTION: 153# @DESCRIPTION:
160# rather than `set` as there are some options only available via that. 160# rather than `set` as there are some options only available via that.
161# 161#
162# A common example is to disable shell globbing so that special meaning/care 162# A common example is to disable shell globbing so that special meaning/care
163# may be used with variables/arguments to custom functions. That would be: 163# may be used with variables/arguments to custom functions. That would be:
164# @CODE 164# @CODE
165# eshopts_push -o noglob 165# eshopts_push -s noglob
166# for x in ${foo} ; do 166# for x in ${foo} ; do
167# if ...some check... ; then 167# if ...some check... ; then
168# eshopts_pop 168# eshopts_pop
169# return 0 169# return 0
170# fi 170# fi
171# done 171# done
172# eshopts_pop 172# eshopts_pop
173# @CODE 173# @CODE
174eshopts_push() { 174eshopts_push() {
175 # have to assume __ESHOPTS_SAVE__ isn't screwed with
176 # as a `declare -a` here will reset its value
177 if [[ $1 == -[su] ]] ; then 175 if [[ $1 == -[su] ]] ; then
178 estack_push eshopts "$(shopt -p)" 176 estack_push eshopts "$(shopt -p)"
179 [[ $# -eq 0 ]] && return 0 177 [[ $# -eq 0 ]] && return 0
180 shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*" 178 shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
181 else 179 else

Legend:
Removed from v.1.373  
changed lines
  Added in v.1.376

  ViewVC Help
Powered by ViewVC 1.1.20