Rex
Rex copied to clipboard
Confusing results when calling run_task on undefined target
Describe the bug
When calling my $return = run_task $task, on => undef;, the value of $return is always 1.
(Originally reported by @sdondley via IRC, thanks!)
How to reproduce it
Steps to reproduce the behavior:
- Call
run_taskwithon => undef.
Shortest code example that demonstrates the bug:
task 'abc', sub {
return 'abc';
};
task 'run_task_undef', sub {
my $return = run_task 'abc', on => undef;
say $return;
};
Expected behavior
While a task's returned value might not be well-defined, it would be nice to have as consistent behavior as possible between the various calls. In this case, returning "abc" instead of 1.
Currently run_task $task, on => undef seems to execute on the same target as the calling task, which might be confusing and/or error-prone. Perhaps it's best to die() with an error message in this case.
Circumstances
- Rex version: current master
- Perl version: 5.32.0
- OS running rex: Gentoo
- OS managed by rex: Gentoo
- How rex was installed: dzil install