Fix debug output crashing commands (thx @guyhd)

fixes #4226