From 9ccda5baa25686a5074ba19ae190f7e1db4ddcf9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 19 May 2008 20:58:47 -0700 Subject: [PATCH] add --clean option to bti.c --- bti.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bti.c b/bti.c index 1c5a856..29599f5 100644 --- a/bti.c +++ b/bti.c @@ -44,7 +44,7 @@ struct session { char *password; char *account; char *tweet; - int quiet; + int clean; }; struct bti_curl_buffer { @@ -293,9 +293,9 @@ int main(int argc, char *argv[], char *envp[]) { "debug", 0, NULL, 'd' }, { "account", 1, NULL, 'a' }, { "password", 1, NULL, 'p' }, - { "bash", 1, NULL, 'b' }, { "help", 0, NULL, 'h' }, - { "quiet", 0, NULL, 'q' }, + { "clean", 0, NULL, 'c' }, + { "version", 0, NULL, 'v' }, { } }; struct session *session; @@ -337,12 +337,15 @@ int main(int argc, char *argv[], char *envp[]) session->password = strdup(optarg); dbg("password = %s\n", session->password); break; - case 'q': - session->quiet = 1; + case 'c': + session->clean = 1; break; case 'h': display_help(); goto exit; + case 'v': + display_version(); + goto exit; default: display_help(); goto exit; @@ -370,17 +373,20 @@ int main(int argc, char *argv[], char *envp[]) } /* Add the "PWD $ " to the start of the tweet to show it is - * coming from a shell */ + * coming from a shell unless --clean is specified. */ tweet = get_string_from_stdin(); - session->tweet = zalloc(strlen(tweet) + strlen(dir) + 10); - sprintf(session->tweet, "%s $ %s", dir, tweet); - free(tweet); - - if (strlen(session->tweet) == 0) { + if (strlen(tweet) == 0) { dbg("no tweet?\n"); return -1; } + session->tweet = zalloc(strlen(tweet) + strlen(dir) + 10); + if (session->clean) + sprintf(session->tweet, "%s", tweet); + else + sprintf(session->tweet, "%s $ %s", dir, tweet); + free(tweet); + dbg("account = %s\n", session->account); dbg("password = %s\n", session->password); dbg("tweet = %s\n", session->tweet); -- 2.39.5