hielke
Re:What does " 2>&1 " mean?
on Friday February 27, 2026 @10:39AM (#47181778)
With exec you can open file descriptors of your current process.
if [[ ! -e /proc/$$/fd/3 ]]; then
# check if fd 3 already open and if not open, open it to /dev/null
exec 3>/dev/null
fi
>&3 echo "will print on fd 3"
This will fix the error you are describing while keeping the functionality intact.Now with that exec trick the fun only gets started. Because you can redirect to subshells and subshells inherit their redirection of the parent:
set -x # when debugging, print all commands ran prefixed with CMD:
PID=$$
BASH_XTRACEFD=7
LOG_FILE=/some/place/to/your/log/or/just/stdout
exec 3> >(gawk '!/^RUN \+ echo/{ print strftime("[%Y-%m-%d %H:%M:%S] <PID:'$PID'> "), $0; fflush() }' >> $LOG_FILE)
exec > >(sed -u 's/^/INFO: /' >&3)
exec 2> >(sed -u 's/^/ERROR: /' >&3)
exec 7> >(sed -u 's/^/CMD: /' >&3)
exec 8>&1 #normal stdout with >&8
exec 9>&2 #normal stderr with >&9
And now your bash script will have a nice log with stdout and stderr prefixed with INFO and ERROR and has timestamps with the PID.Now the disclaimer is that you will not have gaurantees that the order of stdout and stderr will be correct unfortunately, even though we run it unbuffered (-u and fflush).
Re:The (history of) spice must flow
on Friday February 09, 2024 @05:13AM (#39313331)
The phrase in the title is also not from Frank Herbert. It is from Lynch's movie adaptation of the books.
Re:#include <rules>
on Sunday February 04, 2024 @11:10AM (#39251404)
>Do modules actually make compilation appreciably faster in msvc?
For a small toy example, about 10x times faster. Don't know how that looks in real life projects.
Re:#include <rules>
on Sunday February 04, 2024 @07:54AM (#39249824)
In modern C++ there will be modules (C++20). Even std will be available as a module (C++23). This will likely bring down compile times massively. But so far the only compiler with support for this today is MSVC.
Re:Learn AutoHotKey by stealing my scripts
on Tuesday August 22, 2023 @06:40AM (#37220846)
I was stuck on the same struggles, but eventually managed to bodge something together:
https://github.com/hwalinga/dotfiles/blob/master/CapsLockCtr...
It also implements the double feature functionality of CapsLock that now functions as Ctrl when pressed with another key, and just Esc when tapped.