A peek at POSIX sh's future goodies


While it feels like POSIX.1-2024 got released just yesterday and a lot of shells/coreutils still aren't fully conformant (e.g. test -nt/-ot in bash/zsh, read -d or OpenBSD/NetBSD/MacOS often lagging behind), I've been perusing the Austin Group bug tracker to get an idea of what's (almost certainly?) slated for the coming Issue 9.

mktemp -d §

Link

That's the big one, alright. Especially with -d mind you, as POSIX already had echo 'mkstemp(/tmp/tmp.XXXXXX)' | m4 for the file variant (as used in my current shim).

Some of you may underestimate how often you want temporary directories in scripts.

xargs -P §

Link

Together with the previously standardized -0 option and NPROCESSOR_ONLN, finally an ergonomic way to get parallel command execution! A bit of duck taping later and we got tr '\n' '\000' | xargs -n1 -r -0 -P$(getconf NPROCESSOR_ONLN) $cmd. Even more fiddling and the use of sh -c '...' argv0 as command can get you almost everything you could want from GNU parallel modulo the distributed features (cf pararun).

The rest §

Some comparatively less important stuff in no specific order:

  • \A and \z in (extended) regular expressions, link.
  • vi/ex -u RCFILE to specify a different configuration, link.
  • find -perm /OCTAL to match files with any of their mode's bits set in OCTAL, link.
  • xargs -o to reopen stdin as /dev/tty in order to use with interactive commands, link.

And finally, two interesting requests currently in the "Under Review" state: standardize more grep and diff options.