Skip to content
Browse files

Split --background from --bash, and make the latter imply the former.

This allows to use send-in-background without mangling the message's text.
  • Loading branch information...
1 parent d90f61a commit ddc247f995f3b343187ea65720078a4220bd5a0a @Flameeyes Flameeyes committed with Aug 27, 2010
Showing with 30 additions and 9 deletions.
  1. +7 −1 bti.1
  2. +10 −4 bti.c
  3. +13 −4 bti.xml
View
8 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
View
14 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);
View
17 bti.xml
@@ -214,11 +214,20 @@
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>

0 comments on commit ddc247f

Please sign in to comment.
Something went wrong with that request. Please try again.