From a16af0dbaa43957ff4f3e3b33fef73f2e403ff78 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 08 Sep 2012 17:39:03 -0400 Subject: Implement _ob_local and _ob_return. --- (limited to 'lib') 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 . + +[ -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 +} -- cgit v0.9.1