Browse Source

Now support aliases + hosts on command line at the same time

Héctor García 6 years ago
parent
commit
da3f60d820
1 changed files with 10 additions and 13 deletions
  1. 10 13
      src/mssh.c

+ 10 - 13
src/mssh.c

@@ -337,23 +337,20 @@ int main(int argc, char* argv[], char* env[])
         }
     }
 
-    if(hosts == NULL)
-    {
-        hosts = g_array_new(FALSE, TRUE, sizeof(char*));
-        if (optind < argc)
-        {
-            while (optind < argc)
-            {
-                char *host = strdup(argv[optind++]);
-                g_array_append_val(hosts, host);
-            }
+    if (optind < argc) {
+        if (hosts == NULL) {
+            hosts = g_array_new(FALSE, TRUE, sizeof(char*));
         }
-        else
+        while (optind < argc)
         {
-            fprintf(stderr, "No hosts specified\n\n");
-            usage(argv[0]);
+            char *host = strdup(argv[optind++]);
+            g_array_append_val(hosts, host);
         }
     }
+    if (hosts == NULL) {
+        fprintf(stderr, "No hosts specified\n\n");
+        usage(argv[0]);
+    }
 
     gtk_init(&argc, &argv);