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

Diff of /eclass/eutils.eclass

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

Revision 1.374 Revision 1.375
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.374 2011/12/17 03:57:38 reavertm Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.375 2011/12/17 04:55:41 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
176 # as a `declare -a` here will reset its value 176 # as a `declare -a` here will reset its value
177 local i=${#__ESHOPTS_SAVE__[@]} 177 local i=${#__ESHOPTS_SAVE__[@]}
178 if [[ $1 == -[su] ]] ; then 178 if [[ $1 == -[su] ]] ; then
179 __ESHOPTS_SAVE__[$i]=$(shopt -p) 179 __ESHOPTS_SAVE__[$i]=$(shopt -p)
180 [[ $# -eq 0 ]] && return 0 180 [[ $# -eq 0 ]] && return 0
181 shopt "$@" || die "eshopts_push: bad options to shopt: $*" 181 shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*"
182 else 182 else
183 __ESHOPTS_SAVE__[$i]=$- 183 __ESHOPTS_SAVE__[$i]=$-
184 [[ $# -eq 0 ]] && return 0 184 [[ $# -eq 0 ]] && return 0
185 set "$@" || die "eshopts_push: bad options to set: $*" 185 set "$@" || die "${FUNCNAME}: bad options to set: $*"
186 fi 186 fi
187} 187}
188 188
189# @FUNCTION: eshopts_pop 189# @FUNCTION: eshopts_pop
190# @USAGE: 190# @USAGE:
191# @DESCRIPTION: 191# @DESCRIPTION:
192# Restore the shell options to the state saved with the corresponding 192# Restore the shell options to the state saved with the corresponding
193# eshopts_push call. See that function for more details. 193# eshopts_push call. See that function for more details.
194eshopts_pop() { 194eshopts_pop() {
195 [[ $# -ne 0 ]] && die "eshopts_pop takes no arguments" 195 [[ $# -ne 0 ]] && die "${FUNCNAME} takes no arguments"
196 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 )) 196 local i=$(( ${#__ESHOPTS_SAVE__[@]} - 1 ))
197 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair" 197 [[ ${i} -eq -1 ]] && die "eshopts_{push,pop}: unbalanced pair"
198 local s=${__ESHOPTS_SAVE__[$i]} 198 local s=${__ESHOPTS_SAVE__[$i]}
199 unset __ESHOPTS_SAVE__[$i] 199 unset __ESHOPTS_SAVE__[$i]
200 if [[ ${s} == "shopt -"* ]] ; then 200 if [[ ${s} == "shopt -"* ]] ; then
201 eval "${s}" || die "eshopts_pop: sanity: invalid shopt options: ${s}" 201 eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
202 else 202 else
203 set +$- || die "eshopts_pop: sanity: invalid shell settings: $-" 203 set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-"
204 set -${s} || die "eshopts_pop: sanity: unable to restore saved shell settings: ${s}" 204 set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}"
205 fi 205 fi
206} 206}
207 207
208# @FUNCTION: eumask_push 208# @FUNCTION: eumask_push
209# @USAGE: <new umask> 209# @USAGE: <new umask>

Legend:
Removed from v.1.374  
changed lines
  Added in v.1.375

  ViewVC Help
Powered by ViewVC 1.1.20