ensure all output goes to stderr in cd hook, fix #2521