No magic on Mac. I had three examples, but none of those are what you tried.
As you can see I used the tee command after a pipe character (|).
What you did just redirected the error stream to the standard output and did nothing with it, and also independently redirected the standard output (which was empty) to build.log. To give you an example to test what happened, create the following script as output.sh
>&1 echo "stdout"
>&2 echo "stderr"
Make it executable:
chmod +x output.sh
and run the following command:
my-cript.sh > out1.log > out2.log
It will just redirect the standard output to two different log files. This is the same as the following command:
my-cript.sh 1> out1.log 1> out2.log
You could redirect the error logs multiple times too
my-cript.sh 1> out1.log 1> out2.log 2> err1.log 2> err2.log
Then run the following command to get the stderr and stdout two times
cat *.log
stderr
stderr
stdout
stdout
So these redirections are not chained, but independent.
If you don’t like the tee command, your solution could work with parenthesis:
(my-script.sh 2>&1) > build.log
This way my-script.sh 2>&1 would run first and the result would be redirected to the build log. I think it would just complicate things as my first original example would redirect everything the same way without parenthesis and without the tee command.
In your case:
my-script.sh &> build.log
Notice the & character instead of 1 or 2.