[PATCH 0/1] MR9975: where: Add quiet mode.
From: Thomas Csovcsity <thc.fr13nd@gmail.com> --- programs/where/main.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/programs/where/main.c b/programs/where/main.c index 3307ace1f45..bd24d57b411 100644 --- a/programs/where/main.c +++ b/programs/where/main.c @@ -25,9 +25,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(where); +#define OPT_QUIET 0x00000001 + static BOOL found; -static void search(const WCHAR *search_path, const WCHAR *pattern) +static void search(const WCHAR *search_path, const WCHAR *pattern, DWORD flags) { static const WCHAR *extensions[] = {L"", L".bat", L".cmd", L".com", L".exe"}; WCHAR glob[MAX_PATH]; @@ -56,7 +58,8 @@ static void search(const WCHAR *search_path, const WCHAR *pattern) { if (PathCombineW(match_path, search_path, match.cFileName)) { - printf("%ls\n", match_path); + if(!(flags & OPT_QUIET)) + printf("%ls\n", match_path); found = TRUE; } } @@ -69,13 +72,25 @@ static void search(const WCHAR *search_path, const WCHAR *pattern) int __cdecl wmain(int argc, WCHAR *argv[]) { WCHAR *pattern, *colon, *search_paths, *search_path, *next_search_path; + DWORD flags = 0; int i; for (i = 0; i < argc; i++) { - if (argv[i][0] == '/') + if (argv[i][0] == '/' && wcslen(argv[i]) == 2) + { + switch(toupper(argv[i][1])) + { + case 'Q': flags |= OPT_QUIET; break; + default: + FIXME("Unsupported option %ls -- %c\n", argv[i], argv[i][1]); + return 1; + + } + } + else if (argv[i][0] == '/') { - FIXME("Unsupported option %ls\n", argv[i]); + FIXME("Unsupported option %ls len %lld\n", argv[i], (long long)wcslen(argv[i])); return 1; } } @@ -104,17 +119,18 @@ int __cdecl wmain(int argc, WCHAR *argv[]) /* If the search paths were not explicitly specified, search the current directory first */ WCHAR current_dir[MAX_PATH]; if (GetCurrentDirectoryW(ARRAY_SIZE(current_dir), current_dir)) - search(current_dir, pattern); + search(current_dir, pattern, flags); } next_search_path = wcsdup(search_paths); while ((search_path = wcstok(NULL, L";", &next_search_path))) - search(search_path, pattern); + search(search_path, pattern, flags); } if (!found) { - fputs("File not found\n", stderr); + if(!(flags & OPT_QUIET)) + fputs("File not found\n", stderr); return 1; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9975
Nikolay Sivov (@nsivov) commented about programs/where/main.c:
int __cdecl wmain(int argc, WCHAR *argv[]) { WCHAR *pattern, *colon, *search_paths, *search_path, *next_search_path; + DWORD flags = 0; int i;
for (i = 0; i < argc; i++) { - if (argv[i][0] == '/') + if (argv[i][0] == '/' && wcslen(argv[i]) == 2) + { + switch(toupper(argv[i][1])) + { + case 'Q': flags |= OPT_QUIET; break; This should simply check for Q and q.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128017
On Mon Jan 26 21:23:34 2026 +0000, Nikolay Sivov wrote:
This should simply check for Q and q. ATM yes, but i tried be prepared for more command line options to parse and support. I had a look at xcopy, how cmdline parsing is handled.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128032
eric pouech (@epo) commented about programs/where/main.c:
- if (argv[i][0] == '/') + if (argv[i][0] == '/' && wcslen(argv[i]) == 2) + { + switch(toupper(argv[i][1])) + { + case 'Q': flags |= OPT_QUIET; break; + default: + FIXME("Unsupported option %ls -- %c\n", argv[i], argv[i][1]); + return 1; + + } + } + else if (argv[i][0] == '/') { - FIXME("Unsupported option %ls\n", argv[i]); + FIXME("Unsupported option %ls len %lld\n", argv[i], (long long)wcslen(argv[i])); %Iu
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128111
eric pouech (@epo) commented about programs/where/main.c:
int __cdecl wmain(int argc, WCHAR *argv[]) { WCHAR *pattern, *colon, *search_paths, *search_path, *next_search_path; + DWORD flags = 0; int i;
for (i = 0; i < argc; i++) not from your MR, but starting at 0 is wrong
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128113
eric pouech (@epo) commented about programs/where/main.c:
int __cdecl wmain(int argc, WCHAR *argv[]) { WCHAR *pattern, *colon, *search_paths, *search_path, *next_search_path; + DWORD flags = 0; int i;
for (i = 0; i < argc; i++) { - if (argv[i][0] == '/') + if (argv[i][0] == '/' && wcslen(argv[i]) == 2) but you don't handle options in second loop, and to /q still will be handled as pattern argument
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128114
On Tue Jan 27 08:25:52 2026 +0000, eric pouech wrote:
%Iu %zu aka size_t would be more accurate, no?
Or just %u, it's not like Windows argv can go above 64KB. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128115
On Tue Jan 27 08:33:52 2026 +0000, Alfred Agrell wrote:
%zu aka size_t would be more accurate, no? Or just %u, it's not like Windows argv can go above 64KB. `%zu` insn't supported by mingw gcc (PE side)
and `%u` won't work on 64bit (PE side) (unless you cast the arg, which we tend to avoid) `%zu` should be used Unix side though (I wrote `%Iu` but default font in gitlab can be confusing, so updated first post with fixed size font) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128135
On Tue Jan 27 11:57:00 2026 +0000, eric pouech wrote:
`%zu` insn't supported by mingw gcc (PE side) and `%u` won't work on 64bit (PE side) (unless you cast the arg, which we tend to avoid) `%zu` should be used Unix side though (I wrote `%Iu` but default font in gitlab can be confusing, so updated first post with fixed size font) Printing the len of the string we just printed is not particularly useful...
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128136
On Tue Jan 27 08:32:25 2026 +0000, eric pouech wrote:
but you don't handle options in second loop, and to /q still will be handled as pattern argument I do not see your point. It parses '/Q' and prints fixme statement for not supported '/' parameters. The second for loop starting at line 98, parses the rest as before and ignores all patterns with '/', see line 115.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128152
On Tue Jan 27 14:26:06 2026 +0000, Alexandre Julliard wrote:
Printing the len of the string we just printed is not particularly useful... Thanks for the hints. I go with not printing len, because it adds no value.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9975#note_128153
participants (6)
-
Alexandre Julliard (@julliard) -
Alfred Agrell (@Alcaro) -
eric pouech (@epo) -
Nikolay Sivov (@nsivov) -
Thomas Csovcsity -
Thomas Csovcsity (@thc13)