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

Error when installing to msys2 bash #133

Open
chriswalz opened this issue Mar 2, 2021 · 1 comment
Open

Error when installing to msys2 bash #133

chriswalz opened this issue Mar 2, 2021 · 1 comment

Comments

@chriswalz
Copy link

chriswalz commented Mar 2, 2021

Thanks for making this lib it's quite useful. Please see the error and potential problem outlined below.

10:21:07 chrome@Beast src → bit complete
install completion for bit? y
installing...
regexp: Compile(`^complete -C C:\Users\chrome\go\bin\bit.exe bit$`): error parsing regexp: invalid escape sequence: `\U`

goroutine 1 [running]:
runtime/debug.Stack(0xf51840, 0xc000006018, 0xc00011cc78)
        C:/Dev/Go/src/runtime/debug/stack.go:24 +0xa5
github.com/chriswalz/bit/cmd.HandleExit()
        C:/Users/chrome/go/pkg/mod/github.com/chriswalz/bit@v1.0.1/cmd/util.go:320 +0xea
panic(0xe0cfe0, 0xc0000533f0)
        C:/Dev/Go/src/runtime/panic.go:965 +0x1c7
regexp.MustCompile(0xc000376510, 0x30, 0x1)
        C:/Dev/Go/src/regexp/regexp.go:311 +0x15f
github.com/chriswalz/complete/v3/install.lineInFile(0xc00001cd38, 0x17, 0xc0003764b0, 0x2e, 0x2)
        C:/Users/chrome/go/pkg/mod/github.com/chriswalz/complete/v3@v3.0.12/install/utils.go:12 +0x12c
github.com/chriswalz/complete/v3/install.bash.IsInstalled(0xc00001cd38, 0x17, 0xea613a, 0x3, 0xc000376450, 0x1e, 0x2)
        C:/Users/chrome/go/pkg/mod/github.com/chriswalz/complete/v3@v3.0.12/install/bash.go:15 +0xfc
github.com/chriswalz/complete/v3/install.bash.Install(0xc00001cd38, 0x17, 0xea613a, 0x3, 0xc000376450, 0x1e, 0x0, 0x0)
        C:/Users/chrome/go/pkg/mod/github.com/chriswalz/complete/v3@v3.0.12/install/bash.go:19 +0x77
github.com/chriswalz/complete/v3/install.Install(0xea613a, 0x3, 0xc00011d350, 0xe)
        C:/Users/chrome/go/pkg/mod/github.com/chriswalz/complete/v3@v3.0.12/install/install.go:66 +0xf6

According to this comment the problem is due to:

  1. https://github.com/posener/complete/blob/master/install/bash.go#L36

  2. https://github.com/posener/complete/blob/master/install/bash.go#L15

  3. https://github.com/posener/complete/blob/master/install/utils.go#L12

The code seems to assume that cmd or bin doesn't contain any regexp characters. The 3. probably should escape all those characters. It's weird that it's using regexps for that in the first place.

@posener
Copy link
Owner

posener commented Mar 13, 2021

Makes sense, never tested on Windows, would love to have a PR fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants