Re: [libvirt] [PATCH 1/4] virsh: Do not make interactive mode default

2015-09-04 Thread Ján Tomko
On Fri, Sep 04, 2015 at 01:10:03PM +0200, Erik Skultety wrote:
> Currently, we set interactive mode as default possibly reverting the
> setting after we parse the command line arguments. There's nothing
> particulary wrong with that, but a call to vshReadlineInit is performed
> always in the global initializer just because the default mode is interactive.
> Rather than moving vshReadlineInit call somewhere else (because another client
> might want to implement interactive mode only), we could make the decision
> if we're about to run in interactive mode once the command line is parsed.
> ---
>  tools/virsh.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 

Moving this patch after the introduction of vshInitReload would make
sure that vshReadlineInit is called correctly in every intermediate
commit.

Jan


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 1/4] virsh: Do not make interactive mode default

2015-09-04 Thread Erik Skultety
Currently, we set interactive mode as default possibly reverting the
setting after we parse the command line arguments. There's nothing
particulary wrong with that, but a call to vshReadlineInit is performed
always in the global initializer just because the default mode is interactive.
Rather than moving vshReadlineInit call somewhere else (because another client
might want to implement interactive mode only), we could make the decision
if we're about to run in interactive mode once the command line is parsed.
---
 tools/virsh.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 391c155..a71cd47 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -786,7 +786,9 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
 longindex = -1;
 }
 
-if (argc > optind) {
+if (argc == optind) {
+ctl->imode = true;
+} else {
 /* parse command */
 ctl->imode = false;
 if (argc - optind == 1) {
@@ -846,7 +848,6 @@ main(int argc, char **argv)
 memset(ctl, 0, sizeof(vshControl));
 memset(, 0, sizeof(virshControl));
 ctl->name = "virsh";/* hardcoded name of the binary */
-ctl->imode = true;  /* default is interactive mode */
 ctl->log_fd = -1;   /* Initialize log file descriptor */
 ctl->debug = VSH_DEBUG_DEFAULT;
 ctl->hooks = 
-- 
2.4.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list