unzip: fflush stdout before reading interative y/n answer from stdin
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 9 Sep 2011 15:30:55 +0000 (17:30 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 9 Sep 2011 15:30:55 +0000 (17:30 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/unzip.c

index 4fa729326dc6deafb52dd14ed56ea2ac040ce7bc..4cc98cdb2794c04a2acf9c8afc86fb422a539d97 100644 (file)
@@ -235,7 +235,7 @@ static void unzip_create_leading_dirs(const char *fn)
        /* Create all leading directories */
        char *name = xstrdup(fn);
        if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
-               bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */
+               xfunc_die(); /* bb_make_directory is noisy */
        }
        free(name);
 }
@@ -595,7 +595,7 @@ int unzip_main(int argc, char **argv)
                                        }
                                        unzip_create_leading_dirs(dst_fn);
                                        if (bb_make_directory(dst_fn, dir_mode, 0)) {
-                                               bb_error_msg_and_die("exiting");
+                                               xfunc_die();
                                        }
                                } else {
                                        if (!S_ISDIR(stat_buf.st_mode)) {
@@ -619,6 +619,7 @@ int unzip_main(int argc, char **argv)
                                                        i = 'y';
                                                } else {
                                                        printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
+                                                       fflush_all();
                                                        if (!fgets(key_buf, sizeof(key_buf), stdin)) {
                                                                bb_perror_msg_and_die("can't read input");
                                                        }