From acbd9b9832efddbf57d13684c672202de34dbc3f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 22 Sep 2012 13:35:09 +0200 Subject: fb-helper: only display progress bar is stderr is a tty If fb is used in a cronjob we don't care about the progress bar. Signed-off-by: Florian Pritz --- fb-helper.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'fb-helper.c') diff --git a/fb-helper.c b/fb-helper.c index 56e33c3..cfde5c3 100644 --- a/fb-helper.c +++ b/fb-helper.c @@ -13,6 +13,8 @@ * (see COPYING for full license text) */ +#define _POSIX_C_SOURCE 1 + #include #include #include @@ -20,6 +22,7 @@ #include #include #include +#include #include #include @@ -304,10 +307,12 @@ int main(int argc, char *argv[]) CURLFORM_END); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); - /* display progress bar */ - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &cb_data); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + if (isatty(fileno(stderr)) == 1) { + /* display progress bar*/ + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &cb_data); + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); + } } /* initialize custom header list (stating that Expect: 100-continue is not -- cgit v1.2.3-24-g4f1b