jesseduffield.lazygit/pkg
Stefan Haller 6b311ccb62 Fix quoting of shell commands on Windows
lazygit builds a shell command by interpolating Quote'd arguments into a
template and running the result via `cmd /c`. Several things were wrong
on Windows:

- Quote emitted bash-style `\"…\"` quoting, which cmd.exe doesn't
  understand. Making it usable at all previously required a fragile
  round-trip through str.ToArgv and re-escaping.
- The assembled command line was handed to `cmd /c` without `/s`, so
  cmd's default rules stripped the wrong quotes once the line contained
  more than two of them (e.g. a quoted editor path at a location with
  spaces, plus a quoted filename that also contains spaces).
- Shell metacharacters were escaped with `^` (`&` → `^&`, etc.), which
  neutralised command chaining, pipes, redirection and `%VAR%` expansion
  in custom commands.

Quote now emits the standard Windows convention directly, and NewShell
hands cmd.exe the fully-assembled line verbatim via SysProcAttr.CmdLine,
wrapped as `cmd /s /c "<command>"`. The /s flag strips exactly the outer
quote pair we add, leaving each argument's own quoting intact. With the
`^` escaping gone, metacharacters in a custom command reach cmd as the
author intended; this also removes the spurious `^` reported in #3092.

Fixes #5560
Fixes #2427
Fixes #4147

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:11:00 +02:00
..
app Offer direnv .envrc approval from inside lazygit 2026-06-04 09:05:01 +02:00
cheatsheet Render every key for a binding in the cheatsheet 2026-05-25 15:18:18 +02:00
commands Fix quoting of shell commands on Windows 2026-06-23 14:11:00 +02:00
common Move NewDummyCommon to pkg/common 2025-05-06 09:43:26 +02:00
config Add config options for external change detection 2026-06-19 18:07:48 +02:00
constants Make the links in the status panel point to the current version rather than master 2024-03-22 08:13:59 +01:00
env Support bare worktrees where worktree does not have its own .git file 2023-08-07 22:40:53 +10:00
fakes Modernize all codes 2025-11-15 10:46:23 +01:00
gocui Extend the fill background to wrapped tail segments 2026-06-18 17:22:31 +02:00
gui Remove bespoke commit selection restoration when starting a rebase 2026-06-23 09:20:05 +02:00
i18n Allow cycling pagers in reverse 2026-06-07 15:51:57 +02:00
integration Document running the integration tests via the just recipes 2026-06-23 13:31:03 +02:00
jsonschema Fold legacy quit-alt1 into the multi-key quit binding 2026-05-25 15:32:47 +02:00
logs Fix Windows linter errors 2026-06-16 16:21:13 +02:00
snake Enable intrange linter, and fix warnings 2025-06-30 18:30:11 +02:00
tasks Fix linter warnings about ignoring errors from bufio.Scanner 2026-05-03 16:57:24 +02:00
theme Copy gocui files into lazygit repo under pkg/gocui 2026-04-30 14:29:08 +02:00
updates Change direct access to Common.UserConfig to a getter 2024-08-18 10:24:52 +02:00
utils Make UnixToDateSmart timezone-deterministic 2026-05-02 17:59:27 +02:00