The current one is a derivative of NetBSD's implementation (where it shells out to use a sh builtin)
- this piece of code is 2BSD-licensed
- it calls out to /bin/sh
- on OS X, /bin/sh is hardlinked to /bin/bash
- OS X's bash is GPLv2
Forking to shell is the only way to reuse bash's code. More often than not I really wish sh were not bash.
well, the other obvius way is to license this piece of code as GPLv2.
https://github.com/freebsd/freebsd/blob/master/lib/libc/gen/...
It looks very similar to the current OSX file posted in an earlier comment. Calls /bin/sh too.