aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-05-22 17:41:22 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-05-23 23:04:45 +0800
commit0b81725ba19e24f5fbbe7e0026058aa93f6a9965 (patch)
tree7f860606c1ce541d12ff86d7ced1e965e7bc9ce1 /utils/isolated-functions.sh
parentAPI: allow sourcing a script before interpreting (diff)
downloadlibbash-0b81725ba19e24f5fbbe7e0026058aa93f6a9965.tar.gz
libbash-0b81725ba19e24f5fbbe7e0026058aa93f6a9965.tar.bz2
libbash-0b81725ba19e24f5fbbe7e0026058aa93f6a9965.zip
Utility: support misc functions for instruo
"has", "hasq" and "die" are supported for instruo.
Diffstat (limited to 'utils/isolated-functions.sh')
-rwxr-xr-xutils/isolated-functions.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/utils/isolated-functions.sh b/utils/isolated-functions.sh
new file mode 100755
index 0000000..efbf933
--- /dev/null
+++ b/utils/isolated-functions.sh
@@ -0,0 +1,22 @@
+die(){
+ echo "Die is called. Something went wrong while interpreting"
+}
+
+has() {
+ hasq "$@"
+}
+
+hasq() {
+ for item in ${*:2}
+ do
+ [[ $item == $1 ]] && return 0
+ done
+ return 1
+}
+
+EXPORT_FUNCTIONS() {
+ if [ -z "$ECLASS" ]; then
+ die "EXPORT_FUNCTIONS without a defined ECLASS"
+ fi
+ $__export_funcs_var="$__export_funcs_var $*"
+}