---
title: "chezmoi: shell quoting and diff fixes in Go | VulCode"
description: "Two fixes to chezmoi in Go: shellQuote no longer doubles backslashes inside single quotes, and apply --interactive diffs a new file against /dev/null."
url: "https://vulcode.com/en/opensource/contributions/chezmoi"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

twpayne/chezmoi

# chezmoi

A dotfiles manager that keeps the same settings on many different machines, securely.

[See the repository](https://github.com/twpayne/chezmoi) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: Go
- **GitHub stars**: 22,342
- **Merged changes**: 2
- **Project site**: [chezmoi.io](https://www.chezmoi.io/)

## What we changed

shellQuote no longer doubles backslashes inside single quotes, and choosing diff in apply --interactive for a file that does not exist yet compares it with /dev/null, the way chezmoi diff does.

### What this work shows

- POSIX sh quoting

- Calling external commands from Go

- txtar script tests

What was broken

### shellQuote doubled backslashes

Inside POSIX sh single quotes a backslash has no special meaning, yet shellQuote doubled it. For the value \n the function returned '\\n', so the shell received different text from the one in the template.

How we fixed it

### Backslashes are kept as they are

shellQuote now copies a backslash unchanged, while a single quote still closes the quoted run and gets a backslash before it. Tests cover \n and \', and we checked a few quoted values through sh -c.

[#5233](https://github.com/twpayne/chezmoi/pull/5233)

What was broken

### Diffing a new file passed a missing path

Choosing diff in apply --interactive for a file that is not on disk yet passed the destination path to diff.command. The external diff program was handed a file that does not exist.

How we fixed it

### A new file is compared with /dev/null

The command now gets /dev/null, or NUL: on Windows, as in chezmoi diff, through the same DevNullAbsPath function. A test in diffcommand_unix.txtar uses a diff command that fails if any argument does not exist.

[#5232](https://github.com/twpayne/chezmoi/pull/5232)

## Merged changes 2

- [#5233 fix: Don't double backslashes in shellQuote Merged 11 October 2026](https://github.com/twpayne/chezmoi/pull/5233)

- [#5232 fix: Pass /dev/null to diff command for missing files in apply --interactive Merged 11 October 2026](https://github.com/twpayne/chezmoi/pull/5232)

## What it taught us

Inside POSIX sh single quotes a backslash means nothing, so quoting has to leave it as it is. A tool that calls an outside program has to hand it paths that exist, on Linux and on Windows.

[More about this technology: Golang](https://vulcode.com/en/technologies/go)

## Other projects we write code for

- [**urfave/cli** Go · 24,329 stars A declarative Go package for building command line tools.](https://vulcode.com/en/opensource/contributions/urfave-cli)

- [**goquery** Go · 14,995 stars A Go library for traversing and changing HTML documents in the style of jQuery, built on the golang.org/x/net/html parser.](https://vulcode.com/en/opensource/contributions/goquery)

- [**Ebitengine** Go · 13,647 stars A 2D game engine in Go, used in games released for computers, phones, browsers and consoles.](https://vulcode.com/en/opensource/contributions/ebiten)

- [**Fission** Go · 8,950 stars A serverless functions framework for Kubernetes that runs code as functions and scales them down to zero when they are idle.](https://vulcode.com/en/opensource/contributions/fission)

- [**Concourse** Go · 7,944 stars A container-based automation system written in Go and used mostly for CI/CD. Pipelines and tasks are described in YAML files.](https://vulcode.com/en/opensource/contributions/concourse)

- [**dromara/carbon** Go · 5,225 stars A Go package for dates and times with a simple, readable API, with helpers such as the start and end of a minute, a day or a century.](https://vulcode.com/en/opensource/contributions/dromara-carbon)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
