Skip to content

Commit

Permalink
Fix generate --clip (gopasspw#1846)
Browse files Browse the repository at this point in the history
This was broken in a refactoring.

Fixes gopasspw#1844

RELEASE_NOTES=[BUGFIX] Fix generate -c

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz authored Mar 18, 2021
1 parent 01017f8 commit 3157d29
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/action/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,15 @@ func (s *Action) generateCopyOrPrint(ctx context.Context, c *cli.Context, name,

out.OKf(ctx, "Password for entry %q generated", entry)

if !ctxutil.IsTerminal(ctx) && (s.cfg.AutoClip || IsClip(ctx)) {
// copy to clipboard if:
// - explicitly requested with -c
// - autoclip=true, but only if output is not being redirected
if IsClip(ctx) || (s.cfg.AutoClip && !ctxutil.IsTerminal(ctx)) {
if err := clipboard.CopyTo(ctx, name, []byte(password), s.cfg.ClipTimeout); err != nil {
return ExitError(ExitIO, err, "failed to copy to clipboard: %s", err)
}
// if autoclip is on and we're not printing the password to the terminal
// at least leave a notice that we did indeed copy it
if s.cfg.AutoClip && !c.Bool("print") {
out.Print(ctx, "Copied to clipboard")
return nil
Expand Down

0 comments on commit 3157d29

Please sign in to comment.