fish --version should write to stdout

When explicitly asking for the fish version string the information
should go to stdout rather than stderr. Also, there is no reason to use
exit_without_destructors() rather than exit() in that code path. We
actually want the side-effects of exit() such as flushing stdout and
there aren't any threads or other things that could cause a normal exit
to fail when that function is run.
This commit is contained in:
Kurtis Rader 2016-03-23 11:42:17 -07:00
parent 2a4a539d86
commit de1258e09b

View file

@ -382,7 +382,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
case 0: case 0:
{ {
fwprintf(stderr, _(L"getopt_long() unexpectedly returned zero\n")); fwprintf(stderr, _(L"getopt_long() unexpectedly returned zero\n"));
exit_without_destructors(127); exit(127);
} }
case 'c': case 'c':
@ -405,8 +405,9 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
} }
else else
{ {
debug(0, _(L"Invalid value '%s' for debug level switch"), optarg); fwprintf(stderr, _(L"Invalid value '%s' for debug level switch"),
exit_without_destructors(1); optarg);
exit(1);
} }
break; break;
} }
@ -444,15 +445,15 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
case 'v': case 'v':
{ {
fwprintf(stderr, _(L"%s, version %s\n"), PACKAGE_NAME, fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME,
get_fish_version()); get_fish_version());
exit_without_destructors(0); exit(0);
} }
default: default:
{ {
// We assume getopt_long() has already emitted a diagnostic msg. // We assume getopt_long() has already emitted a diagnostic msg.
exit_without_destructors(1); exit(1);
} }
} }