]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: minor fixes to make readline work
authorVaclav Dolezal <vdolezal@redhat.com>
Mon, 28 Aug 2017 10:31:10 +0000 (12:31 +0200)
committerVaclav Dolezal <vdolezal@redhat.com>
Mon, 28 Aug 2017 12:03:30 +0000 (14:03 +0200)
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
disk-utils/fdisk.c

index acfbac88786fdd2506cecc7b251ee480a68252a9..261d884bebeca66ad8f5926915928a698505eed5 100644 (file)
@@ -53,8 +53,6 @@
 # include <linux/blkpg.h>
 #endif
 
-#undef HAVE_LIBREADLINE
-
 int pwipemode = WIPEMODE_AUTO;
 int device_is_used;
 int is_interactive;
@@ -141,7 +139,10 @@ int get_user_reply(const char *prompt, char *buf, size_t bufsz)
                        rl_callback_read_char();
                        if (!reply_running && reply_line) {
                                sz = strlen(reply_line);
-                               memcpy(buf, reply_line, min(sz, bufsz));
+                               if (sz == 0)
+                                       buf[0] = '\n';
+                               else
+                                       memcpy(buf, reply_line, min(sz, bufsz));
                                buf[bufsz - 1] = '\0';
                                free(reply_line);
                                reply_line = NULL;