yq
yq copied to clipboard
pathlogical behavior when stdout is redirected to /dev/null
There's something about GitHub's OpenAI schema that causes yq
to hang or at least become very slow but only when stdout is redirected to /dev/null. Weird stuff.
Repro:
# fast
$ curl -sfSL https://raw.githubusercontent.com/github/rest-api-description/618ddb1c3ca74ad843b8dd7a4b3c80dcec298c54/descriptions/ghes-3.6/ghes-3.6.yaml | yq eval . > echo.yml
# hangs
$ curl -sfSL https://raw.githubusercontent.com/github/rest-api-description/618ddb1c3ca74ad843b8dd7a4b3c80dcec298c54/descriptions/ghes-3.6/ghes-3.6.yaml | yq eval . > /dev/null
$ uname -a
Darwin Tamirs-MBP 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64
Reproduces both with yq installed from homebrew and compiled from source.
Looks like this is caused by colorization somehow. --no-colors
makes this fast in all cases. I think this has to do with the double pass required for colorization: https://github.com/mikefarah/yq/blob/33a3bb3bdfbf0ac5e6092e0314be70139c29ee19/pkg/yqlib/encoder_yaml.go#L119.