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

Bug using | more #183

Closed
hellishvictor opened this issue May 29, 2024 · 15 comments
Closed

Bug using | more #183

hellishvictor opened this issue May 29, 2024 · 15 comments

Comments

@hellishvictor
Copy link

Hi, here on Win 7 x64 using | more on:
curl -s https://theunitedstates.io/congress-legislators/legislators-current.json | jaq.exe --color=never .[] | more

it shows:

?┼?=>?┼┼????=>?????
┼????????:?┼┼????????┼???????????┼???????>???????┼??????>????┼???>?┼┼┼??????
┼┼??????
┼??┼┼????????┼?????=>?????????┼????????>???┼┼????????????????┼┼?????>???┼????>????┼????????????┼┼???
?????=>???????
??┼??=>?┼┼????????=?┼┼???>?????┼????????>????????┼?????>?┼┼?????>???????┼┼????>??┼?
????>?┼┼?┼┼┼??=>????┼┼????>???????┼┼┼???????????┼┼???=>?~?┼┼┼?????>??┼┼┼??????????┼┼?
┼?
┼┼????????┼┼┼????????????┼┼??=>???????┼┼┼???????
┼┼?????????┼┼????>??????┼??┼┼?┼┼┼??=>????┼┼????>???????┼┼┼???????????┼┼???=>?~?┼┼┼?????>??┼┼┼???????
???┼┼??┼??┼┼????????┼┼┼???????????
┼┼??=>???????┼┼┼????????┼┼?????????┼┼????>??????┼??┼┼?┼┼┼??=>???
┼┼????>???????┼┼┼???????????┼┼???=>?~?┼┼┼?????>??┼┼┼??????????┼┼?
┼?
┼┼????????┼┼┼????????????┼┼??=>???????┼┼┼???????
┼┼?????????┼┼????>??????┼┼┼??????????????????????┼??┼┼?┼┼┼??=>????┼┼????>???????┼┼┼???????????┼┼???=
>?~?┼┼┼?????>??┼┼┼??????????
┼┼???>??????????????????┼┼??┼??┼┼????????┼┼┼????????????┼┼??=>???????┼┼┼????????┼┼????>?
┼┼????>??????┼┼┼??????????????????┼┼?????>????????????????????????????┼┼???=>????????┼┼┼???????????
┼┼????????????????????????????
┼┼???????????????????????┼??┼┼?┼┼┼??=>???
┼┼????>???????┼┼┼???????????┼┼???=>?~?┼┼┼??????????
┼┼????>??┼┼???>????????????????┼┼┼?????????????????????????????????┼┼┼????????????
┼┼???>????????┼┼┼???????>????????????????????┼┼┼???=>????4?????????????┼┼????????????
-- Más  --

Cheers.

@01mf02
Copy link
Owner

01mf02 commented May 31, 2024

This is very strange. On Linux, I cannot reproduce this problem. What does curl -s https://theunitedstates.io/congress-legislators/legislators-current.json | more give you?

@hellishvictor
Copy link
Author

[
  {
    "id": {
      "bioguide": "B000944",
      "thomas": "00136",
      "lis": "S307",
      "govtrack": 400050,
      "opensecrets": "N00003535",
      "votesmart": 27018,
      "fec": [
        "H2OH13033",
        "S6OH00163"
      ],
      "cspan": 5051,
      "wikipedia": "Sherrod Brown",
      "house_history": 9996,
      "ballotpedia": "Sherrod Brown",
      "maplight": 168,
      "icpsr": 29389,
      "wikidata": "Q381880",
      "google_entity_id": "kg:/m/034s80"
    },
    "name": {
      "first": "Sherrod",
-- Más  --

@01mf02
Copy link
Owner

01mf02 commented May 31, 2024

Ok. Can you tell me the output of the following commands?

curl -s https://theunitedstates.io/congress-legislators/legislators-current.json > legislators-current.json
jaq.exe --color=never .[] legislators-current.json | more

And:

type legislators-current.json | jaq.exe --color=never .[] | more

And:

type legislators-current.json | jaq.exe --color=never .[]

@hellishvictor
Copy link
Author

The first two output the same wrong data that is on the first comment; I just switched to jaq for get more speed, but not problem at all when using jq, dasel, or any other. For examples:

curl -s http://programminghistorian.org/assets/jq_rkm.json | jq.exe .[] | more

48
359
[
  {
    "links": {
      "self": "https://www.rijksmuseum.nl/api/nl/collection/SK-C-5",
      "web": "https://www.rijksmuseum.nl/nl/collectie/SK-C-5"
    },
    "id": "nl-SK-C-5",
    "objectNumber": "SK-C-5",
    "title": "Schutters van wijk II onder leiding van kapitein Frans Banninck Cocq, bekend als de ÔÇ
ÿNachtwachtÔÇÖ",
    "hasImage": true,
    "principalOrFirstMaker": "Rembrandt Harmensz. van Rijn",
    "longTitle": "Schutters van wijk II onder leiding van kapitein Frans Banninck Cocq, bekend als d
e ÔÇÿNachtwachtÔÇÖ, Rembrandt Harmensz. van Rijn, 1642",
    "showImage": true,
    "permitDownload": true,
    "webImage": {
      "guid": "3ae88fe0-021c-41ae-a4ce-cc70b7bc6295",
      "offsetPercentageX": 50,
      "offsetPercentageY": 100,
      "width": 2500,
      "height": 2034,
-- Más  --

curl -s http://programminghistorian.org/assets/jq_rkm.json | dasel -r json -w yaml | more

elapsedMilliseconds: 48
count: 359
artObjects:
  - links:
      self: https://www.rijksmuseum.nl/api/nl/collection/SK-C-5
      web: https://www.rijksmuseum.nl/nl/collectie/SK-C-5
    id: nl-SK-C-5
    objectNumber: SK-C-5
    title: Schutters van wijk II onder leiding van kapitein Frans Banninck Cocq, bekend als de ÔÇÿNa
chtwachtÔÇÖ
    hasImage: true
    principalOrFirstMaker: Rembrandt Harmensz. van Rijn
    longTitle: Schutters van wijk II onder leiding van kapitein Frans Banninck Cocq, bekend als de Ô
ÇÿNachtwachtÔÇÖ, Rembrandt Harmensz. van Rijn, 1642
    showImage: true
    permitDownload: true
    webImage:
      guid: 3ae88fe0-021c-41ae-a4ce-cc70b7bc6295
      offsetPercentageX: 50
      offsetPercentageY: 100
      width: 2500
      height: 2034
      url: http://lh6.ggpht.com/ZYWwML8mVFonXzbmg2rQBulNuCSr3rAaf5ppNcUc2Id8qXqudDL1NSYxaqjEXyDLSbeN
FzOHRu0H7rbIws0Js4d7s_M=s0
-- Más  --

@hellishvictor
Copy link
Author

#177 solved this.

@01mf02
Copy link
Owner

01mf02 commented Jun 19, 2024

Great!

@hellishvictor
Copy link
Author

Hi, it seems that it's not solved, the bug is still on the latest v2.0.0-alpha and also on v1.6.0 (I've downloaded and builded it just for confirm it). Anything I can help let me know.

@hellishvictor hellishvictor reopened this Sep 22, 2024
@01mf02
Copy link
Owner

01mf02 commented Sep 23, 2024

@hellishvictor, can you post the output of the following commands, using v2.0.0-alpha.1?

$ jaq -n '[0]' | more
$ jaq -n --color=never '[0]' | more
$ jaq -n '[0]'
$ jaq -n --color=never '[0]'

@hellishvictor
Copy link
Author

@hellishvictor, can you post the output of the following commands, using v2.0.0-alpha.1?

Here is:

$ jaq -n '[0]' | more
$ jaq -n --color=never '[0]' | more

?┼??

$ jaq -n '[0]'
$ jaq -n --color=never '[0]'
[
  0
]

@01mf02
Copy link
Owner

01mf02 commented Sep 23, 2024

Ok, this is definitely weird.

I've prepared a sample program for you:

use std::io::{self, Write};

fn with_stdout<T>(f: impl FnOnce(&mut io::StdoutLock) -> io::Result<T>) -> io::Result<T> {
    let mut stdout = io::stdout().lock();
    let y = f(&mut stdout)?;
    stdout.flush()?;
    Ok(y)
}

fn main() -> io::Result<()> {
    with_stdout(|out| {
        writeln!(out, "[")?;
        writeln!(out, "  0")?;
        writeln!(out, "]")
    })
}

Can you save the above program as main.rs, compile it with rustc main.rs, then run main.exe | more?
Let us pray that it yields ?┼?? ...

@hellishvictor
Copy link
Author

It does:
?┼??

@01mf02
Copy link
Owner

01mf02 commented Sep 23, 2024

Great. What does the following program do (again running rustc main.rs, then main.exe | more)?

fn main() {
    println!("[");
    println!("  0");
    println!("]");
}

@hellishvictor
Copy link
Author

It outputs the same.

@01mf02
Copy link
Owner

01mf02 commented Sep 24, 2024

OK. Then you'll likely have this behaviour with any Rust program, not just jaq. Therefore, this issue can only be solved at Rust-level. Can you open an issue at https://github.com/rust-lang/rust?

@01mf02
Copy link
Owner

01mf02 commented Oct 9, 2024

Closing this because this issue is not only related to jaq.

@01mf02 01mf02 closed this as completed Oct 9, 2024
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

2 participants