浏览代码

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

Héctor García 7 年之前
父节点
当前提交
da3f60d820
共有 1 个文件被更改,包括 10 次插入13 次删除
  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);