]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rename: ask(): print n when EOF on input
authorG.raud Meyer <graud@gmx.com>
Sat, 31 Mar 2018 13:01:27 +0000 (15:01 +0200)
committerG.raud Meyer <graud@gmx.com>
Mon, 9 Apr 2018 15:21:16 +0000 (17:21 +0200)
misc-utils/rename.c

index 1c24d7e32969315f1a50f7e4765be6e70ddbbb0e..032a039bfac9a5133a803e86cb5fa8ff1eb9d66c 100644 (file)
@@ -65,17 +65,18 @@ static int ask(char *name)
        printf(_("%s: overwrite `%s'? "), program_invocation_short_name, name);
        fflush(stdout);
        if ((c = fgetc(stdin)) == EOF) {
-               buf[0] = '\0';
+               buf[0] = 'n';
                clearerr(stdin); errno = 0;
-               printf("\n");
+               printf("n\n");
        }
        else {
-               buf[0] = c; buf[1] = '\0';
+               buf[0] = c;
                if (c != '\n' && tty_cbreak) /* no purge necessary */
                        printf("\n");
                else if (c != '\n')
                        while ((c = fgetc(stdin)) != '\n' && c != EOF);
        }
+       buf[1] = '\0';
        if (rpmatch(buf) == RPMATCH_YES)
                return 0;
        else