Do not prompt for overwrite when reading from STDIN
Fixes
@@ -21,17 +21,6 @@ func (s *Action) Insert(c *cli.Context) error {
return fmt.Errorf("provide a secret name")
}
- replacing, err := s.Store.Exists(name)
- if err != nil && err != password.ErrNotFound {
- return fmt.Errorf("failed to see if %s exists", name)
- }
-
- if !force { // don't check if it's force anyway
- if replacing && !askForConfirmation(fmt.Sprintf("An entry already exists for %s. Overwrite it?", name)) {
- return fmt.Errorf("not overwriting your current secret")
- }
- }
-
info, err := os.Stdin.Stat()
if err != nil {
return fmt.Errorf("Failed to stat stdin: %s", err)
@@ -48,6 +37,17 @@ func (s *Action) Insert(c *cli.Context) error {
return s.Store.SetConfirm(name, content.Bytes(), "Read secret from STDIN", s.confirmRecipients)
}
+ replacing, err := s.Store.Exists(name)
+ if err != nil && err != password.ErrNotFound {
+ return fmt.Errorf("failed to see if %s exists", name)
+ }
+
+ if !force { // don't check if it's force anyway
+ if replacing && !askForConfirmation(fmt.Sprintf("An entry already exists for %s. Overwrite it?", name)) {
+ return fmt.Errorf("not overwriting your current secret")
+ }
+ }
+
// if multi-line input is requested start an editor
if multiline {
content, err := s.editor([]byte{})
