]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: Write out history on "quit" or "exit" in interactive mode
authorJohn Ferlan <jferlan@redhat.com>
Wed, 28 Sep 2016 19:01:55 +0000 (15:01 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 29 Sep 2016 11:00:28 +0000 (07:00 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1379895

Introduced by commit id '834c5720'.

During the code motion and creation of vsh.c, the function 'vshDeinit()'
in the (new) vsh.c was altered from whence it came in virsh.c such that
calling 'vshReadlineDeinit(ctl)' was conditional on "ctl->imode".

This causes a problem for the interactive running if the "quit" and "exit"
commands are used because 'cmdQuit' will clear ctl->imode, thus when the
interactive loop in main() of virsh.c exits because ctl->mode is clear and
virshDeinit is called which calls vshDeinit, the history file is now not
written. Conversely, if one had exited the interactive loop via pressing
<ctrl>D the file would be created because loop control is broken on EOF
and ctl->imode is not set to false.

This patch will remove the conditional call to vshReadlineDeinit and
restore the former behaviour.

tools/vsh.c

index 041113f2b4d274eedaa5fe33ce30e3ace8375020..cdd1cba81ed02aedef64a73ebc5ddc4dbbb5ab8f 100644 (file)
@@ -3093,8 +3093,9 @@ vshInitReload(vshControl *ctl)
 void
 vshDeinit(vshControl *ctl)
 {
-    if (ctl->imode)
-        vshReadlineDeinit(ctl);
+    /* NB: Don't make calling of vshReadlineDeinit conditional on active
+     * interactive mode. */
+    vshReadlineDeinit(ctl);
     vshCloseLogFile(ctl);
 }