diff --git a/tools/power/acpi/tools/acpidump/apfiles.c b/tools/power/acpi/tools/acpidump/apfiles.c index a42cfcaa3293..16d919bd133b 100644 --- a/tools/power/acpi/tools/acpidump/apfiles.c +++ b/tools/power/acpi/tools/acpidump/apfiles.c @@ -29,18 +29,24 @@ static int ap_is_existing_file(char *pathname) { #if !defined(_GNU_EFI) && !defined(_EDK2_EFI) struct stat stat_info; + int in_char; if (!stat(pathname, &stat_info)) { fprintf(stderr, "Target path already exists, overwrite? [y|n] "); - if (getchar() != 'y') { + in_char = fgetc(stdin); + if (in_char == '\n') { + in_char = fgetc(stdin); + } + + if (in_char != 'y' && in_char != 'Y') { return (-1); } } #endif - return 0; + return (0); } /******************************************************************************