aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--scripts/isolated_functions.bash13
-rw-r--r--scripts/isolated_functions.bash.result12
-rw-r--r--utils/variable_printer.cpp11
4 files changed, 37 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index f55db28..15d4b65 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -52,6 +52,7 @@ BASH_TESTS = scripts/var_def.bash \
scripts/command_execution.bash \
scripts/function_def.bash \
scripts/arithmetic_assignment.bash \
+ scripts/isolated_functions.bash \
scripts/compound_command.bash \
scripts/test_expr.bash \
scripts/binary_arithmetic.bash
@@ -60,6 +61,7 @@ BASH_RESULT = scripts/var_def.bash.result \
scripts/command_execution.bash.result \
scripts/function_def.bash.result \
scripts/arithmetic_assignment.bash.result \
+ scripts/isolated_functions.bash.result \
scripts/compound_command.bash.result \
scripts/test_expr.bash.result \
scripts/binary_arithmetic.bash.result
diff --git a/scripts/isolated_functions.bash b/scripts/isolated_functions.bash
new file mode 100644
index 0000000..ffdc14d
--- /dev/null
+++ b/scripts/isolated_functions.bash
@@ -0,0 +1,13 @@
+die "something wrong"
+has 123 456 123 456 && echo true
+has 123 456 13 456 && echo false
+hasq 123 123 456
+EXPORT_FUNCTIONS
+echo hi
+use
+useq
+use_with
+use_enable
+eerror foo
+debug-print foo
+ewarn foo
diff --git a/scripts/isolated_functions.bash.result b/scripts/isolated_functions.bash.result
new file mode 100644
index 0000000..a56974f
--- /dev/null
+++ b/scripts/isolated_functions.bash.result
@@ -0,0 +1,12 @@
+Die is called: something wrong
+true
+Die is called: EXPORT_FUNCTIONS without a defined ECLASS
+hi
+use shouldn't be called
+useq shouldn't be called
+use_with shouldn't be called
+use_enable shouldn't be called
+eerror: foo
+debug-print: foo
+ewarn: foo
+item=123
diff --git a/utils/variable_printer.cpp b/utils/variable_printer.cpp
index 252ee9b..9104273 100644
--- a/utils/variable_printer.cpp
+++ b/utils/variable_printer.cpp
@@ -36,6 +36,15 @@ static const std::vector<std::string> special_variables
"IFS", "?", "*", "0"
};
+static std::string get_src_dir()
+{
+ std::string srcdir(".");
+ if(getenv("srcdir"))
+ srcdir = getenv("srcdir");
+
+ return srcdir;
+}
+
int main(int argc, char** argv)
{
if(argc != 2)
@@ -48,7 +57,7 @@ int main(int argc, char** argv)
std::vector<std::string> functions;
try
{
- libbash::interpret(argv[1], variables, functions);
+ libbash::interpret(argv[1], get_src_dir() + "/utils/isolated-functions.sh", variables, functions);
}
catch(interpreter_exception& e)
{