Bläddra i källkod

Added support to define more than one alias on command line

Héctor García 7 år sedan
förälder
incheckning
2fdfe0bc67
1 ändrade filer med 7 tillägg och 2 borttagningar
  1. 7 2
      src/mssh.c

+ 7 - 2
src/mssh.c

@@ -236,7 +236,7 @@ int main(int argc, char* argv[], char* env[])
     long cols = 0;
     GData **aliases = NULL;
     GData **commands = NULL;
-    GArray *hosts = NULL;
+    GArray *hosts = NULL, *tmp_hosts = NULL;
 
     static struct option long_options[] =
     {
@@ -274,12 +274,17 @@ int main(int argc, char* argv[], char* env[])
         switch(c)
         {
         case 'a':
-            if(aliases && (hosts = g_datalist_get_data(aliases,
+            if(aliases && (tmp_hosts = g_datalist_get_data(aliases,
                 optarg)) == NULL)
             {
                 fprintf(stderr, "Alias '%s' not found\n\n", optarg);
                 usage(argv[0]);
             }
+            if (hosts == NULL) {
+                hosts = tmp_hosts;
+            } else {
+                g_array_append_vals (hosts, tmp_hosts->data, tmp_hosts->len);
+            }
             break;
         case 'c':
             errno = 0;