# use this from bash, like:
# . P command args
# . P command args
# wait
# . P_logs

if [ -z "$P_log_i" ]; then
	P_log_i=0
fi

P_main() {
	local tmp=$HOME/tmp
	local i_zero_pad=$(printf %06d $P_log_i)
	local i_space_pad=$(printf %6d $P_log_i)
	local logfile=$tmp/P_$$_$i_zero_pad.log
	"$@" 2>&1 | tee "$logfile" | prepend "$i_space_pad"$'\t' >&2 &
	P_log_i=$((P_log_i+1))
}

P_main "$@"
