diff --git a/doc_src/cmds/fish_indent.rst b/doc_src/cmds/fish_indent.rst index 444185d38..a6058e075 100644 --- a/doc_src/cmds/fish_indent.rst +++ b/doc_src/cmds/fish_indent.rst @@ -22,7 +22,7 @@ The following options are available: - ``-i`` or ``--no-indent`` do not indent commands; only reformat to one job per line. -- ``-c`` or ``--check`` do not indent, only return 0 if the code is already indented as fish_indent would, 1 otherwise. +- ``-c`` or ``--check`` do not indent, only return 0 if the code is already indented as fish_indent would, the number of failed files otherwise. Also print the failed filenames if not reading from stdin. - ``-v`` or ``--version`` displays the current fish version and then exits. diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 0ad3ca488..41f190b3f 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -959,6 +959,8 @@ int main(int argc, char *argv[]) { argc -= optind; argv += optind; + int retval = 0; + wcstring src; for (int i = 0; i < argc || (argc == 0 && i == 0); i++) { if (argc == 0 && i == 0) { @@ -1028,7 +1030,10 @@ int main(int argc, char *argv[]) { } case output_type_check: { if (output_wtext != src) { - return 1; + if (argc) { + std::fwprintf(stderr, _(L"%s\n"), argv[i]); + } + retval++; } break; } @@ -1036,5 +1041,5 @@ int main(int argc, char *argv[]) { std::fputws(str2wcstring(colored_output).c_str(), stdout); } - return 0; + return retval; }