diff options
author | 2011-05-22 17:41:22 +0800 | |
---|---|---|
committer | 2011-05-23 23:04:45 +0800 | |
commit | 0b81725ba19e24f5fbbe7e0026058aa93f6a9965 (patch) | |
tree | 7f860606c1ce541d12ff86d7ced1e965e7bc9ce1 /utils | |
parent | API: allow sourcing a script before interpreting (diff) | |
download | libbash-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')
-rw-r--r-- | utils/instruo.cpp | 2 | ||||
-rwxr-xr-x | utils/isolated-functions.sh | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/utils/instruo.cpp b/utils/instruo.cpp index da020c3..8206b95 100644 --- a/utils/instruo.cpp +++ b/utils/instruo.cpp @@ -103,7 +103,7 @@ void worker(const std::shared_ptr<PackageIDSequence> &ids) variables["PVR"][0] + ".ebuild"); try { - libbash::interpret(ebuild_path, variables, functions); + libbash::interpret(ebuild_path, "utils/isolated-functions.sh", variables, functions); } catch(const interpreter_exception& e) { 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 $*" +} |