Piping Text To An External Program Appends A Trailing Newline

tl;dr: When PowerShell pipes a string to an external program: It encodes it using the character encoding stored in the $OutputEncoding preference variable It invariably appends a trailing (platform-appropriate) newline. Therefore, the key is to avoid PowerShell’s pipeline in favor of the native shell’s, so as to prevent implicit addition of a trailing newline: If … Read more

Why exit code 141 with grep -q?

This is because grep -q exits immediately with a zero status as soon as a match is found. The zfs command is still writing to the pipe, but there is no reader (because grep has exited), so it is sent a SIGPIPE signal from the kernel and it exits with a status of 141. Another … Read more

Disable AVX-optimized functions in glibc (LD_HWCAP_MASK, /etc/ld.so.nohwcap) for valgrind & gdb record

It looks like there is a nice workaround for this implemented in recent versions of glibc: a “tunables” feature that guides selection of optimized string functions. You can find a general overview of this feature here and the relevant code inside glibc in ifunc-impl-list.c. Here’s how I figured it out. First, I took the address … Read more