jesseduffield / jesseduffield/lazygit
Custom command does not work like expected
- Dominant language
- Go
- Stars
- 82.4k
- Forks
- 3k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 19
Description
**Describe the bug**
`customCommands.command` field can't properly escape characters.
I guess that the escape character will be passed to the executable. In my case the CMD.
**To Reproduce**
Steps to reproduce the behavior:
1. Add to config:
``` yaml
customCommands:
- key: ''
command: "Powershell -NoProfile -WindowStyle Hidden -command \"& { gps > C:\\S\\temp\\test.txt }\""
context: 'localBranches'
subprocess: true
loadingText: 'creating branch'
```
2. navigate to local branches
3. press ctrl+p
**Expected behavior**
I would expect to have a new file at C:\S\temp\test.txt
It works like a charm with:
1. windows -> Open *Run* with `Win+r`
2. enter *the same command without escape characters*
```
C:\WINDOWS\system32\cmd.exe /c Powershell -NoProfile -WindowStyle Hidden -command "& { gps > C:\S\temp\test.txt }"
```
**Screenshots**
- the same with `echo`

I'm not sure why the character `"` has a problem and the `\` not.
## Test with CMD
If I enter the suspected command with all escape characters from `config.yml`
```
C:\WINDOWS\system32\cmd.exe /c Powershell -NoProfile -WindowStyle Hidden -command \"& { gps > C:\S\temp\test.txt }\"
```
the response is the same like in the screenshot:
```
& { gps > C:\S\temp\test.txt }
```
**Desktop (please complete the following information):**
- OS: Windows
- Lazygit Version 029
- Powershell 7
- Windows terminal
Did I miss something?
Thanks up front.
Contributor guide
Assessment
This issue has not been assessed yet.