`$*` must be quoted unless it's a command
`%*` must not quoted (already quoted)
1) quoting fixes
2) indentation fixes
3) `while` replaced by `for` loops
4) header comment (taken from source code)
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>