В соседнем треде мне посоветовали, как Разделить stderr и stdout. Спасибо vodz, который предложил следующую функцию:
filter() {
local l n
while read -r l; do
n=${l#\[ninja\]}
[ "x$l" != "x$n" ] && printf "%s\n" "$n" || printf "%s\n" "$l" >&2
done
}
Т.е. для файла «log» со следующим содержанием:
[ninja][72/154] Building C object src/CMakeFiles/git2internal.dir/oid.c.o [ninja][73/154] Building C object src/CMakeFiles/git2internal.dir/parse.c.o [ninja][74/154] Building C object src/CMakeFiles/git2internal.dir/patch.c.o [ninja][75/154] Building C object src/CMakeFiles/git2internal.dir/pack.c.o ../src/pack.c:790:22: warning: incompatible pointer types assigning to 'mz_alloc_func' (aka 'void *(*)(void *, unsigned long, unsigned long)') from 'void *(void *, unsigned int, unsigned int)' [-Wincompatible-pointer-types] obj->zstream.zalloc = use_git_alloc; ^ ~~~~~~~~~~~~~ ../src/pack.c:868:16: warning: incompatible pointer types assigning to 'mz_alloc_func' (aka 'void *(*)(void *, unsigned long, unsigned long)') from 'void *(void *, unsigned int, unsigned int)' [-Wincompatible-pointer-types] stream.zalloc = use_git_alloc; ^ ~~~~~~~~~~~~~ 2 warnings generated. [ninja][76/154] Building C object src/CMakeFiles/git2internal.dir/posix.c.o [ninja][77/154] Building C object src/CMakeFiles/git2internal.dir/patch_generate.c.o [ninja][78/154] Building C object src/CMakeFiles/git2internal.dir/pqueue.c.o [ninja][79/154] Building C object src/CMakeFiles/git2internal.dir/patch_parse.c.oпосле пропускания через фильтр и обработки особым образом должно в stdout.txt быть:
[72/154] Building C object src/CMakeFiles/git2internal.dir/oid.c.o [73/154] Building C object src/CMakeFiles/git2internal.dir/parse.c.o [74/154] Building C object src/CMakeFiles/git2internal.dir/patch.c.o [75/154] Building C object src/CMakeFiles/git2internal.dir/pack.c.o [76/154] Building C object src/CMakeFiles/git2internal.dir/posix.c.o [77/154] Building C object src/CMakeFiles/git2internal.dir/patch_generate.c.o [78/154] Building C object src/CMakeFiles/git2internal.dir/pqueue.c.o [79/154] Building C object src/CMakeFiles/git2internal.dir/patch_parse.c.oа в stderr.txt следующее:
../src/pack.c:790:22: warning: incompatible pointer types assigning to 'mz_alloc_func' (aka 'void *(*)(void *, unsigned long, unsigned long)') from 'void *(void *, unsigned int, unsigned int)' [-Wincompatible-pointer-types] obj->zstream.zalloc = use_git_alloc; ^ ~~~~~~~~~~~~~ ../src/pack.c:868:16: warning: incompatible pointer types assigning to 'mz_alloc_func' (aka 'void *(*)(void *, unsigned long, unsigned long)') from 'void *(void *, unsigned int, unsigned int)' [-Wincompatible-pointer-types] stream.zalloc = use_git_alloc; ^ ~~~~~~~~~~~~~ 2 warnings generated.на терминал при этом печатается:
....xxxxxxx....
Как это реализовано сейчас (внимание, говнокод, эстетам не смотреть):
process_out() {
while read line; do
echo "${line}" >> stdout.txt
/bin/echo -n "."
done < fifoout
}
process_err() {
while read line; do
echo "${line}" >> stderr.txt
/bin/echo -n "x"
done < fifoerr
}
mkfifo fifoout
mkfifo fifoerr
process_out &
process_err &
cat log | filter >fifoout 2>fifoerr
sleep 0.1