termshot icon indicating copy to clipboard operation
termshot copied to clipboard

panic: reached end of file before reaching end identifier

Open aidalgol opened this issue 1 year ago • 3 comments

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

❯ ./result/bin/termshot nu

❯ ls
╭────┬────────────────────────┬─────────┬────────┬───────────────╮
│  # │          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/[email protected]/parse.go:100 +0x88
github.com/gonvenience/bunt.ParseStream.func4()
	github.com/gonvenience/[email protected]/parse.go:172 +0xb8
github.com/gonvenience/bunt.ParseStream({0x6db758?, 0xc00018eb70?}, {0x0, 0x0, 0xc0001e7000?})
	github.com/gonvenience/[email protected]/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/[email protected]/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x9778e0)
	github.com/spf13/[email protected]/command.go:1040 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/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.

aidalgol avatar Feb 04 '23 19:02 aidalgol

Just ran into the same thing.

QuinnyPig avatar Nov 10 '23 21:11 QuinnyPig

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

siiick avatar Feb 02 '24 10:02 siiick

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/[email protected]/parse.go:100 +0x9c
github.com/gonvenience/bunt.ParseStream.func4()
	github.com/gonvenience/[email protected]/parse.go:172 +0xac
github.com/gonvenience/bunt.ParseStream({0x1044a2738?, 0x1400016abd0?}, {0x0, 0x0, 0x140001cc000?})
	github.com/gonvenience/[email protected]/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/[email protected]/command.go:940 +0x5c8
github.com/spf13/cobra.(*Command).ExecuteC(0x104738a80)
	github.com/spf13/[email protected]/command.go:1068 +0x35c
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/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 https://github.com/gonvenience/bunt/issues/48

llimllib avatar May 03 '24 13:05 llimllib