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

panic: reached end of file before reaching end identifier #102

Closed
aidalgol opened this issue Feb 4, 2023 · 4 comments
Closed

panic: reached end of file before reaching end identifier #102

aidalgol opened this issue Feb 4, 2023 · 4 comments
Assignees
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@aidalgol
Copy link

aidalgol commented Feb 4, 2023

I'm trying to use termshot to capture Nushell output, and it panics.

./result/bin/termshot nuls
╭────┬────────────────────────┬─────────┬────────┬───────────────╮
│  # │          name          │  type   │  size  │   modified    │
├────┼────────────────────────┼─────────┼────────┼───────────────┤
│  0 │ CONTRIBUTING.md        │ file    │ 8.4 KB │ 8 hours ago   │
│  1 │ COPYING                │ file    │ 1.1 KB │ 8 hours ago   │
│  2 │ README.md              │ file    │ 6.2 KB │ 2 months ago  │
│  3 │ default.nix            │ file    │  971 B │ a year ago    │
│  4 │ doc                    │ dir     │   23 B │ 8 hours ago   │
│  5 │ flake.nix              │ file    │ 2.3 KB │ 2 months ago  │
│  6 │ lib                    │ dir     │   34 B │ 8 hours ago   │
│  7 │ maintainers            │ dir     │    5 B │ 8 hours ago   │
│  8 │ nixos                  │ dir     │   13 B │ 8 hours ago   │
│  9 │ pkgs                   │ dir     │   18 B │ a year ago    │
│ 10 │ result                 │ symlink │   58 B │ 5 minutes ago │
│ 11 │ update-git-commits.txt │ file    │  740 B │ 2 months ago  │
╰────┴────────────────────────┴─────────┴────────┴───────────────╯exit
panic: reached end of file before reaching end identifier

goroutine 1 [running]:
github.com/gonvenience/bunt.ParseStream.func2(0x7)
	github.com/gonvenience/bunt@v1.3.4/parse.go:100 +0x88
github.com/gonvenience/bunt.ParseStream.func4()
	github.com/gonvenience/bunt@v1.3.4/parse.go:172 +0xb8
github.com/gonvenience/bunt.ParseStream({0x6db758?, 0xc00018eb70?}, {0x0, 0x0, 0xc0001e7000?})
	github.com/gonvenience/bunt@v1.3.4/parse.go:225 +0x4ed
github.com/homeport/termshot/internal/img.(*Scaffold).AddContent(0xc000181bd0, {0x6db758?, 0xc00018eb70?})
	github.com/homeport/termshot/internal/img/output.go:116 +0x39
github.com/homeport/termshot/internal/cmd.glob..func1(0x9778e0?, {0xc0000b33d0?, 0x1, 0x1})
	github.com/homeport/termshot/internal/cmd/root.go:115 +0x4d0
github.com/spf13/cobra.(*Command).execute(0x9778e0, {0xc000016050, 0x1, 0x1})
	github.com/spf13/cobra@v1.6.0/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x9778e0)
	github.com/spf13/cobra@v1.6.0/command.go:1040 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.6.0/command.go:968
github.com/homeport/termshot/internal/cmd.Execute()
	github.com/homeport/termshot/internal/cmd/root.go:144 +0x67
main.main()
	github.com/homeport/termshot/cmd/termshot/main.go:26 +0x17

This is with v0.2.5 of termshot.

@QuinnyPig
Copy link

Just ran into the same thing.

@siiick
Copy link

siiick commented Feb 2, 2024

same issue I ran termshot /bin/zsh to begin the capture sequence

@llimllib
Copy link

llimllib commented May 3, 2024

At least in my case, the error is caused by having OSC8 hyperlinks in the output stream.

One way to reliably cause this failure is to use eza:

# this works fine, without hyperlinks:
$ termshot -c -- eza            
bin  dist  git-ls  go.mod  LICENSE  main.go  Makefile  out.png  README.md  static

# this doesn't, with hyperlinks:
$ termshot -c -- eza --hyperlink                                                             
bin  dist  git-ls  go.mod  LICENSE  main.go  Makefile  out.png  README.md  static
panic: reached end of file before reaching end identifier

goroutine 1 [running]:
github.com/gonvenience/bunt.ParseStream.func2(0x7)
	github.com/gonvenience/bunt@v1.3.5/parse.go:100 +0x9c
github.com/gonvenience/bunt.ParseStream.func4()
	github.com/gonvenience/bunt@v1.3.5/parse.go:172 +0xac
github.com/gonvenience/bunt.ParseStream({0x1044a2738?, 0x1400016abd0?}, {0x0, 0x0, 0x140001cc000?})
	github.com/gonvenience/bunt@v1.3.5/parse.go:225 +0x3b0
github.com/homeport/termshot/internal/img.(*Scaffold).AddContent(0x14000123bb8, {0x1044a2738?, 0x1400016abd0?})
	github.com/homeport/termshot/internal/img/output.go:118 +0x3c
github.com/homeport/termshot/internal/cmd.glob..func1(0x104738a80?, {0x14000132340?, 0x2, 0x4})
	github.com/homeport/termshot/internal/cmd/root.go:120 +0x39c
github.com/spf13/cobra.(*Command).execute(0x104738a80, {0x1400010c060, 0x4, 0x4})
	github.com/spf13/cobra@v1.7.0/command.go:940 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x104738a80)
	github.com/spf13/cobra@v1.7.0/command.go:1068 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/cobra@v1.7.0/command.go:992
github.com/homeport/termshot/internal/cmd.Execute()
	github.com/homeport/termshot/internal/cmd/root.go:162 +0x64
main.main()
	./main.go:26 +0x1c

May be related to gonvenience/bunt#48

harbourmaster pushed a commit to gonvenience/bunt that referenced this issue Jan 4, 2025
Ref: homeport/termshot#220
Ref: homeport/termshot#102

Change skip logic to support both BEL and ST as terminator.
HeavyWombat added a commit to gonvenience/bunt that referenced this issue Jan 4, 2025
Ref: homeport/termshot#220
Ref: homeport/termshot#102

Change skip logic to support both BEL and ST as terminator.
@HeavyWombat
Copy link
Member

I was finally able to reliably reproduce the issue locally. In my case, it was due to bunt only checking for the BEL as the terminator, but the ST is also being used in some use cases. So this might also solve the issue with the examples here. If not, feel free to reopen the issue. Fix is in release https://github.com/homeport/termshot/releases/tag/v0.4.1.

@HeavyWombat HeavyWombat self-assigned this Jan 5, 2025
@HeavyWombat HeavyWombat added bug Something isn't working dependencies Pull requests that update a dependency file labels Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

5 participants