# Escape carets \(^\) in Go test regex \(\#27746\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/5e286897d31c6eece6d9aaa795ac0391fb293fca)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 5e286897d31c6eece6d9aaa795ac0391fb293fca

Requested commit: 5e286897d31c6eece6d9aaa795ac0391fb293fca

Commit: 5e286897d31c6eece6d9aaa795ac0391fb293fca

Tree: 2362bdef78d8d53f7ec50085b241f99178c3459b

Author: Jake

Committer: GitHub

## Message

````
Escape carets (^) in Go test regex (#27746)

This is a follow up to https://github.com/zed-industries/zed/pull/14821,
which escaped `$` but not `^`.

This is fine for `bash`, but causes issues with `zsh`. This change
escapes the `^`. I tested this against `bash`, `zsh` and `fish`

I suspect such escaping would probably need to be done at some
shell-specific layer of the code, but for now it seems like the tasks
provided by the `ContextProvider` are supposed to be shell agnostic.

To reproduce the original issue:
1. Create a Go test file in a module that just contains a single test
`TestABC`.
2. Run `zsh -i -c "go test -run ^TestABC\$"` which is what Zed tries to
run when the task for a specific Go test is executed.
3. An error that there are no tests to run will be produced even though
there is a test.
4. Run `zsh -i -c "go test -run \^TestABC\$"` (note the backslash before
^).
5. The test will run successfully.

Example:
``` go
package bar

import "testing"

func TestABC(t *testing.T) {}
```

Release Notes:

- fix: Escape the ^ in the Go test -run regex to improve shell
compatibility (notably with zsh).
````

## Parents

- [9e38c45a9bc0c4db5d22c16b3021f00a213d3e88](https://git.cafe/gitcafe/zed/commit/9e38c45a9bc0c4db5d22c16b3021f00a213d3e88?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/5e286897d31c6eece6d9aaa795ac0391fb293fca?format=markdown)
