summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-09-08 17:39:03 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-09-08 17:39:03 (EDT)
commita16af0dbaa43957ff4f3e3b33fef73f2e403ff78 (patch)
tree80ded1084730488971ca1765bdf23bb55323e1a7 /lib
parented8fd7222f70fd3a5b9f62b9c3a62e784369d4b8 (diff)
Implement _ob_local and _ob_return.
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh42
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
+}