TwoBitCoders / jx

jx: Memory-Safe JSON Processing using JavaScript implemented in Go
MIT License
48 stars 0 forks source link

Incorrect Output Display in Windows Command Terminal #1

Closed TwoBitC0der closed 1 month ago

TwoBitC0der commented 1 month ago

Description: In JX build 0.0.3, when executing commands in the Windows Command Prompt (CMD), the output displays incorrectly. Specifically, it includes additional unwanted characters and sequences (likely ANSI escape codes) related to the color library. This problem is not present when running the same commands in Windows PowerShell, where the output displays as expected.

See the comparison between PowerShell and CMD in the attached screenshot.

Steps to Reproduce:

Expected Behavior:

The output in both CMD and PowerShell should render clean, readable JSON without extra characters or escape sequences.

Actual Behavior:

In CMD, the output contains unwanted color escape codes, making it unreadable. In PowerShell, the output displays correctly with proper formatting.

Example: In CMD, the output appears as: [1m{[94m"foo"[0m:0[33m[0m}[0m In PowerShell, the expected output is:

{
    "foo": 0
}

Additional Information: JX Build: 0.0.3 Operating System: Windows 11 Pro Terminals Tested: CMD: Output is malformed. PowerShell: Output is correct.

Attachments:

Screenshot showing the comparison between CMD and PowerShell output.

Screenshot 2024-09-17 092926

mftb0 commented 1 month ago

Fixed by adding a dependency on go-colorable

This is a good solution for us because colorable is able to do the required fix-ups for Windows without requiring cgo, which keeps cross-compilation simple.