port pmpf from bash to POSIX shell