]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Make --help and --version work consistently across all tools.
authorSimon Tatham <anakin@pobox.com>
Wed, 19 Sep 2012 17:08:15 +0000 (17:08 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 19 Sep 2012 17:08:15 +0000 (17:08 +0000)
Well, at least across all command-line tools on both Windows and Unix,
and the GTK apps on Unix too. The Windows GUI apps fundamentally can't
write to standard output and it doesn't seem sensible to use message
boxes for these purposes :-)

[originally from svn r9673]

cmdgen.c
pscp.c
psftp.c
unix/gtkwin.c
unix/uxplink.c
windows/winplink.c

index 5b0e54d9afec3f849a6e4259c7c871f3f3d1fe2c..86a548e3a8926cb92ac65a6b38e041163ec002ef 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -118,10 +118,7 @@ void sk_cleanup(void)
 
 void showversion(void)
 {
-    char *verstr = dupstr(ver);
-    verstr[0] = tolower((unsigned char)verstr[0]);
-    printf("PuTTYgen %s\n", verstr);
-    sfree(verstr);
+    printf("puttygen: %s\n", ver);
 }
 
 void usage(int standalone)
diff --git a/pscp.c b/pscp.c
index 833e46cd8ad41bd73dc9d061ee3c8901ae5c9278..054e437b926c5fc8963b756725d5748ab032178c 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -2283,9 +2283,12 @@ int psftp_main(int argc, char *argv[])
            preserve = 1;
        } else if (strcmp(argv[i], "-q") == 0) {
            statistics = 0;
-       } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-?") == 0) {
+       } else if (strcmp(argv[i], "-h") == 0 ||
+                   strcmp(argv[i], "-?") == 0 ||
+                   strcmp(argv[i], "--help") == 0) {
            usage();
-       } else if (strcmp(argv[i], "-V") == 0) {
+       } else if (strcmp(argv[i], "-V") == 0 ||
+                   strcmp(argv[i], "--version") == 0) {
             version();
         } else if (strcmp(argv[i], "-ls") == 0) {
            list = 1;
diff --git a/psftp.c b/psftp.c
index ef930bdd53d7d61cd9fce70d7ce7a0e459eb4cfa..ab287dfde838f8855a49caf10cb4e83232c134db 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -2923,12 +2923,14 @@ int psftp_main(int argc, char *argv[])
            if (flags & FLAG_VERBOSE)
                verbose = 1;
        } else if (strcmp(argv[i], "-h") == 0 ||
-                  strcmp(argv[i], "-?") == 0) {
+                  strcmp(argv[i], "-?") == 0 ||
+                   strcmp(argv[i], "--help") == 0) {
            usage();
         } else if (strcmp(argv[i], "-pgpfp") == 0) {
             pgp_fingerprints();
             return 1;
-       } else if (strcmp(argv[i], "-V") == 0) {
+       } else if (strcmp(argv[i], "-V") == 0 ||
+                   strcmp(argv[i], "--version") == 0) {
            version();
        } else if (strcmp(argv[i], "-batch") == 0) {
            console_batch_mode = 1;
index 2c0df9cb220d8910324c5c8e2d5329d27d3aa7ac..bd69fb698b3fe2110e61b3d9cb37129c433aa27e 100644 (file)
@@ -2592,6 +2592,13 @@ static void help(FILE *fp) {
     }
 }
 
+static void version(FILE *fp) {
+    if(fprintf(fp, "%s: %s\n", appname, ver) < 0 || fflush(fp) < 0) {
+       perror("output error");
+       exit(1);
+    }
+}
+
 int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
                struct gui_data *inst, Conf *conf)
 {
@@ -2801,6 +2808,10 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
            help(stdout);
            exit(0);
 
+       } else if(!strcmp(p, "-version") || !strcmp(p, "--version")) {
+           version(stdout);
+           exit(0);
+
         } else if (!strcmp(p, "-pgpfp")) {
             pgp_fingerprints();
             exit(1);
index 0d89622530dbb6819485f939581c86d43ab8a816..560ec386d0f011bcde07c7c9210605a727780877 100644 (file)
@@ -654,8 +654,11 @@ int main(int argc, char **argv)
            } else if (!strcmp(p, "-s")) {
                 /* Save status to write to conf later. */
                use_subsystem = 1;
-           } else if (!strcmp(p, "-V")) {
+           } else if (!strcmp(p, "-V") || !strcmp(p, "--version")) {
                 version();
+           } else if (!strcmp(p, "--help")) {
+                usage();
+                exit(0);
             } else if (!strcmp(p, "-pgpfp")) {
                 pgp_fingerprints();
                 exit(1);
index 7ec98e7fd5bf9e75572d081c7fdada8946d1201a..0abed7ce31f682d0a597ccb490abe915d1f8c93f 100644 (file)
@@ -343,8 +343,10 @@ int main(int argc, char **argv)
            } else if (!strcmp(p, "-s")) {
                /* Save status to write to conf later. */
                use_subsystem = 1;
-           } else if (!strcmp(p, "-V")) {
+           } else if (!strcmp(p, "-V") || !strcmp(p, "--version")) {
                 version();
+           } else if (!strcmp(p, "--help")) {
+                usage();
             } else if (!strcmp(p, "-pgpfp")) {
                 pgp_fingerprints();
                 exit(1);