cue export doesn't work with named pipe
commit 9e7d4d63acf9cfcf7fdc33731dedfe420c0e2689
This command prints the empty object, where it should not:
% cue export cue: <(echo '{"x": 1'})
{}
This works OK if the input treated as JSON or YAML:
rogpeppe@snazzy2:~$ cue export json: <(echo '{"x": 1'})
{
"x": 1
}
rogpeppe@snazzy2:~$ cue export yaml: <(echo '{"x": 1'})
{
"x": 1
}
Something in the stack is probably reading the input twice without realising that reads can be destructive.
It looks like this is probably because cuelang.org/go/cue/load.matchFile opens the file, reads its imports, then closes it again. It should probably do something different for non-regular files.
This is fixed in master:
$ cue export cue: <(echo '{"x": 1'})
{
"x": 1
}
https://review.gerrithub.io/c/cue-lang/cue/+/1194381 added a test case for it, see exec cue export cue: somefile. It's unclear exactly when it got fixed in the last 2.5 years, but that doesn't seem particularly important.