Skip to content

"Overwrite?: y/n" overwrites anyway #127

Description

@Billiam

func checkFile(f string) error {
if utils.FileExists(f) {
fmt.Printf("%s already exists.\n", f)
s, err := askpass.ReadPassphrase("Overwrite (y/n)? ", askpass.RP_ALLOW_STDIN|askpass.RPP_ECHO_ON)
if err != nil {
return err
}
if !bytes.Equal(s, []byte("y")) {
return nil
}
}
return nil
}

The checkFile method returns nil if the prompt returns something other than "y", but then returns nil anyway below. Looking at the call sites, think that an error should be returned instead of nil in this (value != "y") case, and then return nil otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions