Skip to content

Commit

Permalink
fix readline mess when in --bash mode
Browse files Browse the repository at this point in the history
Turns out it was echoing stdin to stdout, which is annoying, you
end up seeing everything that you just typed.
  • Loading branch information
gregkh committed Mar 11, 2009
1 parent d581e72 commit 78f5497
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bti.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,22 @@ static void log_session(struct session *session, int retval)
fclose(log_file);
}

static char *get_string_from_stdin(void)
{
char *temp;
char *string;

string = zalloc(1000);
if (!string)
return NULL;

if (!fgets(string, 999, stdin))
return NULL;
temp = strchr(string, '\n');
*temp = '\0';
return string;
}

int main(int argc, char *argv[], char *envp[])
{
static const struct option options[] = {
Expand Down Expand Up @@ -747,7 +763,7 @@ int main(int argc, char *argv[], char *envp[])

if (session->action == ACTION_UPDATE) {
if (session->bash)
tweet = readline(NULL);
tweet = get_string_from_stdin();
else
tweet = readline("tweet: ");
if (!tweet || strlen(tweet) == 0) {
Expand Down

0 comments on commit 78f5497

Please sign in to comment.