diff -u -r ../chezmoi-1.8.4/cmd/secretpass.go ./cmd/secretpass.go --- ../chezmoi-1.8.4/cmd/secretpass.go 2020-08-12 13:38:36.000000000 +0200 +++ ./cmd/secretpass.go 2020-08-16 11:55:53.549406216 +0200 @@ -3,6 +3,7 @@ import ( "bytes" "fmt" + "os" "os/exec" "github.com/spf13/cobra" @@ -18,8 +19,7 @@ } type passCmdConfig struct { - Command string - unlocked bool + Command string } var passCache = make(map[string]string) @@ -40,19 +40,10 @@ return s } name := c.Pass.Command - if !c.Pass.unlocked { - args := []string{"grep", "$^"} - cmd := exec.Command(name, args...) - cmd.Stdin = c.Stdin - cmd.Stdout = c.Stdout - cmd.Stderr = c.Stderr - if err := cmd.Run(); err != nil { - panic(fmt.Errorf("%s %s: %w", name, chezmoi.ShellQuoteArgs(args), err)) - } - c.Pass.unlocked = true - } args := []string{"show", id} cmd := exec.Command(name, args...) + cmd.Stdin = os.Stdin + cmd.Stderr = os.Stderr output, err := c.mutator.IdempotentCmdOutput(cmd) if err != nil { panic(fmt.Errorf("%s %s: %w", name, chezmoi.ShellQuoteArgs(args), err)) diff -u -r ../chezmoi-1.8.4/testdata/scripts/secretpass.txt ./testdata/scripts/secretpass.txt --- ../chezmoi-1.8.4/testdata/scripts/secretpass.txt 2020-08-12 13:38:36.000000000 +0200 +++ ./testdata/scripts/secretpass.txt 2020-08-16 11:58:00.293406125 +0200 @@ -8,8 +8,6 @@ #!/bin/sh case "$*" in -"grep $^") - ;; "show misc/example.com") echo "examplepassword" ;; @@ -19,12 +17,7 @@ esac -- bin/pass.cmd -- @echo off -REM Matching "grep $^" seems more or less impossible on windows as it -REM is an escape character in the cmd.exe shell. See -REM https://github.com/twpayne/chezmoi/pull/839#issuecomment-670800462 -IF "%*" == "grep $" ( - exit /b 0 -) ELSE IF "%*" == "show misc/example.com" ( +IF "%*" == "show misc/example.com" ( echo | set /p=examplepassword exit /b 0 ) ELSE (