I don't have anything to add to ghostdog74's answer about the right way to do this, but I can cover why it's failing: The shell parses I/O redirections, backgrounding, and a bunch of other things before it does variable expansion, so by the time
$line is replaced by
command 2>&1 & it's too late to recognize
& as anything other than parameters to
You could improve this by using
eval "$line" but even there you'll run into problems with multiline commands (e.g. while loops, if blocks, etc). The
sh approaches don't have this problem.