]> ToastFreeware Gitweb - gregoa/bti.git/commitdiff
Split --background from --bash, and make the latter imply the former.
authorDiego Elio 'Flameeyes' Pettenò <flameeyes@gmail.com>
Fri, 27 Aug 2010 15:07:35 +0000 (17:07 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 2 Sep 2010 01:21:53 +0000 (18:21 -0700)
This allows to use send-in-background without mangling the message's text.

bti.1
bti.c
bti.xml

diff --git a/bti.1 b/bti.1
index 385b5f579f2d6a2dfea8e472158f0b37e8c161c4..778d58de851cba2082f527a159d15864015b9ec1 100644 (file)
--- a/bti.1
+++ b/bti.1
@@ -112,7 +112,13 @@ Verbose mode\&. Print status IDs and timestamps\&.
 .RS 4
 Add the working directory and a \'$\' in the tweet message to help specify it is coming from a command line\&. Don\'t put the working directory and the \'$\' in the tweet message\&.
 .sp
-This mode also does not report back any errors that might have happened when sending the message, and it sends it in the background, returning immediately, allowing the process to continue on\&.
+This option implies
+\fB\-\-background\fR\&.
+.RE
+.PP
+\fB\-\-background\fR
+.RS 4
+Do not report back any errors that might have happened when sending the message, and send it in the background, returning immediately, allowing the user to continue on\&.
 .RE
 .PP
 \fB\-\-version\fR
diff --git a/bti.c b/bti.c
index 20e6d7b728cd3432e65623028faa534c5ba58042..f38b5a07dcac91a2a07717cd08dc056207f92eca 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -90,6 +90,7 @@ struct session {
        char *configfile;
        char *replyto;
        int bash;
+       int background;
        int interactive;
        int shrink_urls;
        int dry_run;
@@ -129,6 +130,7 @@ static void display_help(void)
        fprintf(stdout, "  --shrink-urls\n");
        fprintf(stdout, "  --page PAGENUMBER\n");
        fprintf(stdout, "  --bash\n");
+       fprintf(stdout, "  --background\n");
        fprintf(stdout, "  --debug\n");
        fprintf(stdout, "  --verbose\n");
        fprintf(stdout, "  --dry-run\n");
@@ -681,7 +683,7 @@ static int send_request(struct session *session)
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, curl_buf);
                if (!session->dry_run) {
                        res = curl_easy_perform(curl);
-                       if (res && !session->bash) {
+                       if (res && !session->background) {
                                fprintf(stderr, "error(%d) trying to perform "
                                                "operation\n", res);
                                return -EINVAL;
@@ -1310,6 +1312,7 @@ int main(int argc, char *argv[], char *envp[])
                { "shrink-urls", 0, NULL, 's' },
                { "help", 0, NULL, 'h' },
                { "bash", 0, NULL, 'b' },
+               { "background", 0, NULL, 'B' },
                { "dry-run", 0, NULL, 'n' },
                { "page", 1, NULL, 'g' },
                { "version", 0, NULL, 'v' },
@@ -1461,6 +1464,9 @@ int main(int argc, char *argv[], char *envp[])
                        break;
                case 'b':
                        session->bash = 1;
+                       /* fall-through intended */
+               case 'B':
+                       session->background = 1;
                        break;
                case 'c':
                        if (session->configfile)
@@ -1546,7 +1552,7 @@ int main(int argc, char *argv[], char *envp[])
        }
 
        if (session->action == ACTION_UPDATE) {
-               if (session->bash || !session->interactive)
+               if (session->background || !session->interactive)
                        tweet = get_string_from_stdin();
                else
                        tweet = session->readline("tweet: ");
@@ -1578,7 +1584,7 @@ int main(int argc, char *argv[], char *envp[])
        /* fork ourself so that the main shell can get on
         * with it's life as we try to connect and handle everything
         */
-       if (session->bash) {
+       if (session->background) {
                child = fork();
                if (child) {
                        dbg("child is %d\n", child);
@@ -1587,7 +1593,7 @@ int main(int argc, char *argv[], char *envp[])
        }
 
        retval = send_request(session);
-       if (retval && !session->bash)
+       if (retval && !session->background)
                fprintf(stderr, "operation failed\n");
 
        log_session(session, retval);
diff --git a/bti.xml b/bti.xml
index 4497e6d2a436d453b9c746cb42b4f3e6161f821b..0fba17ff5b48d9036bfe6e28987f61ecf4ab9162 100644 (file)
--- a/bti.xml
+++ b/bti.xml
                 help specify it is coming from a command line.  Don't put the
                 working directory and the '$' in the tweet message.
              </para>
+
+              <para>
+                 This option implies <option>--background</option>.
+              </para>
+            </listitem>
+          </varlistentry>
+          <varlistentry>
+            <term><option>--background</option></term>
+            <listitem>
              <para>
-                This mode also does not report back any errors that might have
-                happened when sending the message, and it sends it in the
-                background, returning immediately, allowing the process to
-                continue on.
+                Do not report back any errors that might have
+                happened when sending the message, and send it in the
+                background, returning immediately, allowing the user
+                to continue on.
               </para>
             </listitem>
           </varlistentry>