{"thread":{"id":"7010","subject":"[PATCH] git-send-email: abort/usage on bad option","startedAt":"2007-02-28T04:47:54Z","lastAt":"2007-02-28T04:47:54Z","messageCount":1,"participants":["Michael Coleman"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"35775","messageId":"11726380742591-git-send-email-tutufan@gmail.com","threadId":"7010","inReplyTo":null,"subject":"[PATCH] git-send-email: abort/usage on bad option","fromName":"Michael Coleman","fromEmail":"tutufan@gmail.com","sentAt":"2007-02-28T04:47:54Z","receivedAt":"2007-02-28T04:47:54Z","isPatch":true,"sender":{"key":"tutufan@gmail.com","avatar":null},"body":"Instead of proceeding, abort and give usage message when a bad option\nis seen.\n---\n git-send-email.perl |   97 ++++++++++++++++++++++++++++-----------------------\n 1 files changed, 53 insertions(+), 44 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 6a285bf..a71a192 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -34,6 +34,53 @@ sub readline {\n }\n package main;\n \n+\n+sub usage {\n+\tprint <<EOT;\n+git-send-email [options] <file | directory>...\n+Options:\n+   --from         Specify the \"From:\" line of the email to be sent.\n+\n+   --to           Specify the primary \"To:\" line of the email.\n+\n+   --cc           Specify an initial \"Cc:\" list for the entire series\n+                  of emails.\n+\n+   --bcc          Specify a list of email addresses that should be Bcc:\n+\t\t  on all the emails.\n+\n+   --compose      Use \\$EDITOR to edit an introductory message for the\n+                  patch series.\n+\n+   --subject      Specify the initial \"Subject:\" line.\n+                  Only necessary if --compose is also set.  If --compose\n+\t\t  is not set, this will be prompted for.\n+\n+   --in-reply-to  Specify the first \"In-Reply-To:\" header line.\n+                  Only used if --compose is also set.  If --compose is not\n+\t\t  set, this will be prompted for.\n+\n+   --chain-reply-to If set, the replies will all be to the previous\n+                  email sent, rather than to the first email sent.\n+                  Defaults to on.\n+\n+   --no-signed-off-cc Suppress the automatic addition of email addresses\n+                 that appear in a Signed-off-by: line, to the cc: list.\n+\t\t Note: Using this option is not recommended.\n+\n+   --smtp-server  If set, specifies the outgoing SMTP server to use.\n+                  Defaults to localhost.\n+\n+   --suppress-from Suppress sending emails to yourself if your address\n+                  appears in a From: line.\n+\n+   --quiet\t  Make git-send-email less verbose.  One line per email\n+                  should be all that is output.\n+\n+EOT\n+\texit(1);\n+}\n+\n # most mail servers generate the Date: header, but not all...\n sub format_2822_time {\n \tmy ($time) = @_;\n@@ -120,6 +167,10 @@ my $rc = GetOptions(\"from=s\" => \\$from,\n \t\t    \"dry-run\" => \\$dry_run,\n \t );\n \n+unless ($rc) {\n+    usage();\n+}\n+\n # Verify the user input\n \n foreach my $entry (@to) {\n@@ -311,50 +362,8 @@ if (@files) {\n \t\tprint $_,\"\\n\" for (@files);\n \t}\n } else {\n-\tprint <<EOT;\n-git-send-email [options] <file | directory> [... file | directory ]\n-Options:\n-   --from         Specify the \"From:\" line of the email to be sent.\n-\n-   --to           Specify the primary \"To:\" line of the email.\n-\n-   --cc           Specify an initial \"Cc:\" list for the entire series\n-                  of emails.\n-\n-   --bcc          Specify a list of email addresses that should be Bcc:\n-\t\t  on all the emails.\n-\n-   --compose      Use \\$EDITOR to edit an introductory message for the\n-                  patch series.\n-\n-   --subject      Specify the initial \"Subject:\" line.\n-                  Only necessary if --compose is also set.  If --compose\n-\t\t  is not set, this will be prompted for.\n-\n-   --in-reply-to  Specify the first \"In-Reply-To:\" header line.\n-                  Only used if --compose is also set.  If --compose is not\n-\t\t  set, this will be prompted for.\n-\n-   --chain-reply-to If set, the replies will all be to the previous\n-                  email sent, rather than to the first email sent.\n-                  Defaults to on.\n-\n-   --no-signed-off-cc Suppress the automatic addition of email addresses\n-                 that appear in a Signed-off-by: line, to the cc: list.\n-\t\t Note: Using this option is not recommended.\n-\n-   --smtp-server  If set, specifies the outgoing SMTP server to use.\n-                  Defaults to localhost.\n-\n-  --suppress-from Suppress sending emails to yourself if your address\n-                  appears in a From: line.\n-\n-   --quiet\tMake git-send-email less verbose.  One line per email should be\n-\t\tall that is output.\n-\n-Error: Please specify a file or a directory on the command line.\n-EOT\n-\texit(1);\n+\tprint STDERR \"\\nNo patch files specified!\\n\\n\";\n+\tusage();\n }\n \n # Variables we set as part of the loop over files\n-- \n1.5.0.rc3\n"}]}