diff options
-rw-r--r-- | lib/common.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh new file mode 100644 index 0000000..a11d6e4 --- /dev/null +++ b/lib/common.sh @@ -0,0 +1,42 @@ +# opkbuild +# lib/common +# Functions for stack memory management. +# +# Copyright (C) 2012 Patrick "P. J." McDermott +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +[ -n "${_OB_COMMON_SM}" ] && return 0 +_OB_COMMON_SM='true' + +_OB_STACK_VARS= + +_ob_local() +{ + # Push the variable list onto the stack. + _OB_STACK_VARS="|${@}" +} + +_ob_return() +{ + # Unset the variables at the top of the stack. + unset ${_OB_STACK_VARS##*|} + + # Pop the variable list from the top of the stack. + _OB_STACK_VARS="${_OB_STACK_VARS%|*}" + + # Print the return value. + echo ${1} + return 0 +} |