Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] support option --filter for Windows ug.exe #442

Open
genivia-inc opened this issue Nov 18, 2024 · 1 comment
Open

[FR] support option --filter for Windows ug.exe #442

genivia-inc opened this issue Nov 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@genivia-inc
Copy link
Member

Currently the --filter option is disabled in ug.exe and ugrep.exe because I can't simply port the logic directly to Windows. The Unix-based logic creates a pipe and forks a child process to run the filter on the input, with the output sent to the ugrep search engine.

To support --filter in Windows should not be too complicated with an inherited pipe and CreateProcess. There is also the usual wide character API stuff to support in Windows i.e. CreateProcessW, so that non-ASCII filenames are filtered when passed as % to expand the pathname in the filter command arguments.

I will give it a go.

@genivia-inc genivia-inc added the enhancement New feature or request label Nov 18, 2024
@genivia-inc
Copy link
Member Author

I also want to update --filter to allow quoted commands and arguments. Quoting will permit arguments with spaces, commas and % to be passed verbatim to the filter command.

The --filter manual page should be updated to reflect this. I try to keep the option description brief, but detailed enough:

    --filter=COMMANDS
            Filter files through the specified COMMANDS first before searching.
            COMMANDS is a comma-separated list of `exts:command arguments',
            where `exts' is a comma-separated list of filename extensions and
            `command' is a filter utility.  Files matching one of `exts' are
            filtered.  A `*' matches any file.  The specified `command' may
            include arguments separated by spaces.  An argument may be quoted
            to include spacing, commas or a `%'.  A `%' argument expands into
            the pathname to search.  For example, --filter='pdf:pdftotext % -'
            searches PDF files.  The `%' expands into a `-' when searching
            standard input.  When a `%' is not specified, the filter command
            should read from standard input and write to standard output.
            Option --label=.ext may be used to specify extension `ext' when
            searching standard input.  This option may be repeated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant