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

jq invocation on Windows CMD failing #1

Open
Guent4 opened this issue Jul 10, 2019 · 1 comment
Open

jq invocation on Windows CMD failing #1

Guent4 opened this issue Jul 10, 2019 · 1 comment

Comments

@Guent4
Copy link

Guent4 commented Jul 10, 2019

Hello @Gimi!

Based on https://github.com/Gimi/fluent-plugin-jq/blob/master/lib/fluent/plugin/jq_mixin.rb#L34, it seems like jq is invoked with the filter surrounded by single quotes. This seems to be problematic when invoking on CMD.

For example:

C:\>jq -n --unbuffered -c '.record.source = "C:/var/log" + .record.source | .record.sourcetype = (.tag | ltrimstr("file.")) | .record' 2>&1
'.record.sourcetype' is not recognized as an internal or external command,
operable program or batch file.

Two potential ways to support CMD:

  1. Would it be possible to change the single quotes into double quotes? Changing to double quotes seems to fix the issue for CMD, while not breaking it for bash. Top example is from CMD and bottom is from bash:
C:\>jq -n --unbuffered -c ".record.source = \"C:/var/log\" + .record.source | .record.sourcetype = (.tag | ltrimstr(\"file.\")) | .record" 2>&1
{"source":"C:/var/log","sourcetype":null}
$ jq -n --unbuffered -c ".record.source = \"C:/var/log\" + .record.source | .record.sourcetype = (.tag | ltrimstr(\"file.\")) | .record" 2>&1
{"source":"C:/var/log","sourcetype":null}

Downside of this is that all double quotes would need to be escaped before invoking IO.popen

  1. Create a new build for Windows that uses double quotes.

Let me know if either of these two options look reasonable. I can submit a PR if you want.

Thanks!

@Guent4
Copy link
Author

Guent4 commented Jul 24, 2019

After investigating this more, it doesn't seem like Windows support is going to be as easy as changing the quote character. Would be really cool if this plugin could support Windows! The work around for Windows was to just use record_transformer.

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

No branches or pull requests

1 participant