Open Aludirk opened 7 years ago
Note say_hi
doesn't "return a string", it sets the given variable to HI
. If you set result
you'll conflict with the behavior of run
, which invokes your command in a subshell (thereby not setting the variable in the test's environment).
A simple example:
$ say_hi result
$ echo $result
HI
$ unset result
$ ( say_hi result )
$ echo $result # no output - $result isn't even set
I have a function that return a string:
First, I test it with directly call the function:
The test passes.
Then, I try to test it by using
run
:The test fails and I find that
${result}
is empty.What's wrong with that ?