Skip to content

Commit f25fc7b

Browse files
fix: restore clip flag through fuzzy search in show command (gopasspw#3466)
When 'gopass show -c foo' triggers a fuzzy search (because 'foo' does not exist but e.g. 'foozen' does), the -c flag was silently lost. Root cause: findCmd() re-parsed the clip flag from the cli.Command by calling cmd.Bool("clip"). The show command registers 'clip' as a GenericFlag (*OptionalInt), not a BoolFlag. In urfave/cli v3, cmd.Bool() called on a GenericFlag returns false (the zero value) regardless of what the user passed. This false value overwrote the clip=true that showParseArgs() had already correctly stored in the context. The find command has no clip flag of its own, so the block was always a no-op for the direct 'gopass find' path. For the fuzzy-search path (called from showHandleError), the context already carries the correct clip state, so removing the re-parse block is the right fix. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
1 parent 837919a commit f25fc7b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎internal/action/find.go‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ func (s *searchHandler) FindFuzzy(ctx context.Context, cmd *cli.Command) error {
2929

3030
func (s *searchHandler) findCmd(ctx context.Context, cmd *cli.Command, cb showFunc, fuzzy bool) error {
3131
ctx = ctxutil.WithGlobalFlags(ctx, cmd)
32-
if cmd.IsSet("clip") {
33-
ctx = WithOnlyClip(ctx, cmd.Bool("clip"))
34-
ctx = WithClip(ctx, cmd.Bool("clip"))
35-
}
32+
// Note: do not re-parse the clip flag here. The find command has no clip flag,
33+
// and when called via fuzzy search from show, the context already carries the
34+
// correct clip state set by showParseArgs. Calling cmd.Bool("clip") on the show
35+
// command's GenericFlag (OptionalInt) returns false in cli v3, which would
36+
// incorrectly overwrite the clip=true already stored in ctx.
3637

3738
if cmd.IsSet("unsafe") {
3839
ctx = ctxutil.WithForce(ctx, cmd.Bool("unsafe"))

0 commit comments

Comments
 (0)
⌂ 换网址