Don't echo output in scripts.
[libguestfs.git] / fish / fish.c
index 812197c..132c52c 100644 (file)
@@ -277,17 +277,21 @@ rl_gets (int prompt)
 {
 #ifdef HAVE_LIBREADLINE
 
-  if (line_read) {
-    free (line_read);
-    line_read = NULL;
-  }
+  if (prompt) {
+    if (line_read) {
+      free (line_read);
+      line_read = NULL;
+    }
 
-  line_read = readline (prompt ? FISH : "");
+    line_read = readline (prompt ? FISH : "");
 
-  if (prompt && line_read && *line_read)
-    add_history_line (line_read);
+    if (line_read && *line_read)
+      add_history_line (line_read);
 
-#else /* !HAVE_LIBREADLINE */
+    return line_read;
+  }
+
+#endif /* HAVE_LIBREADLINE */
 
   static char buf[8192];
   int len;
@@ -300,8 +304,6 @@ rl_gets (int prompt)
     if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0';
   }
 
-#endif /* !HAVE_LIBREADLINE */
-
   return line_read;
 }