Fix the behaviour of flags like --help and --version; fixes trac #2620