In the last post (damn, has it been that long, again?), I wrote something about how to correctly handle
tee‘d output and return values in your bash scripts.
If you want to capture all output of your script - as you should, because error messages always pop up in a place you did not expect them - you can use this construct:
#!/bin/bash exec > >(tee -a logfile.txt) exec 2> >(tee -a logfile.txt >&2)
This will write all output to the console and
There is an artifact though, in that the output of the script appears after the new shell prompt. This is somewhat ugly, and gives the impression of a “hanging” script at first glance. If anyone knows a way around that, I would be happy to read about it in the comments (and update this post accordingly).
Hopefully there will be time for a topical rant again some day.