From 2a7554025a5735bfd5e8a7b4427d2a49aaf51e93 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 1 Jul 2024 22:11:00 +0200 Subject: [PATCH] fix: Prevent chezmoi add from adding chezmoi's own executable --- internal/cmd/addcmd.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/cmd/addcmd.go b/internal/cmd/addcmd.go index f94028a6f8a..881ae20a8c4 100644 --- a/internal/cmd/addcmd.go +++ b/internal/cmd/addcmd.go @@ -3,6 +3,7 @@ package cmd import ( "fmt" "io/fs" + "os" "github.com/spf13/cobra" @@ -177,6 +178,11 @@ func (c *Config) runAddCmd(cmd *cobra.Command, args []string, sourceState *chezm return err } + executable, err := os.Executable() + if err != nil { + return err + } + return sourceState.Add( c.sourceSystem, c.persistentState, @@ -199,6 +205,7 @@ func (c *Config) runAddCmd(cmd *cobra.Command, args []string, sourceState *chezm c.getConfigFileAbsPath().Dir(), persistentStateFileAbsPath, c.sourceDirAbsPath, + chezmoi.NewAbsPath(executable), }, ReplaceFunc: c.defaultReplaceFunc, Template: c.Add.template,