]> ToastFreeware Gitweb - gregoa/bti.git/blobdiff - bti.c
bti: suppress prompt if fed from a pipe
[gregoa/bti.git] / bti.c
diff --git a/bti.c b/bti.c
index 285fdfadc7471063a1d6bfd7a2135c47edefb065..02b8aea5c0d8b231871ede345e68384b301f044f 100644 (file)
--- a/bti.c
+++ b/bti.c
@@ -83,6 +83,7 @@ struct session {
        char *hosturl;
        char *hostname;
        int bash;
+       int interactive;
        int shrink_urls;
        int dry_run;
        int page;
@@ -172,8 +173,11 @@ static void session_readline_init(struct session *session)
        int (*bind_key)(int, void *);
        void (*insert)(void);
 
-       /* default to internal function if we can't find anything */
+       /* default to internal function if we can't or won't find anything */
        session->readline = get_string;
+       if (!isatty(0))
+               return;
+       session->interactive = 1;
 
        tmp = malloc(strlen(libpath)+1);
        if (!tmp)
@@ -1245,7 +1249,7 @@ int main(int argc, char *argv[], char *envp[])
        }
 
        if (session->action == ACTION_UPDATE) {
-               if (session->bash)
+               if (session->bash || !session->interactive)
                        tweet = get_string_from_stdin();
                else
                        tweet = session->readline("tweet: ");