Why do we want to adhere to POSIX?
$ man bash | grep slow
It's too big and too slow.
$ rpm -qi dash | tail -3
DASH is a POSIX-compliant implementation of /bin/sh that aims to be as small as
possible. It does this without sacrificing speed where possible. In fact, it is
significantly faster than bash (the GNU Bourne-Again SHell) for most tasks.
So let's find out how this function works in dash. $ ./testtrim
./testtrim
$ sed -i 's/dash/bash/' testtrim
$ ./testtrim
foo bar
I think I will pass.