Rex icon indicating copy to clipboard operation
Rex copied to clipboard

Confusing results when calling run_task on undefined target

Open ferki opened this issue 4 years ago • 0 comments

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:

  1. Call run_task with on => 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

~~Debug log~~

ferki avatar Jan 27 '21 17:01 ferki