summaryrefslogtreecommitdiffstats
path: root/fb-helper.c
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2012-09-22 13:35:09 +0200
committerFlorian Pritz <bluewind@xinu.at>2012-09-22 13:35:09 +0200
commitacbd9b9832efddbf57d13684c672202de34dbc3f (patch)
treefe6c4a6842e7883fef9f8d4663e5b854243ab3a4 /fb-helper.c
parent7f65005a8956617d26c874705ef79e994f1b63da (diff)
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 <bluewind@xinu.at>
Diffstat (limited to 'fb-helper.c')
-rw-r--r--fb-helper.c13
1 files changed, 9 insertions, 4 deletions
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 <stdio.h>
#include <sys/time.h>
#include <sys/stat.h>
@@ -20,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
+#include <unistd.h>
#include <curl/curl.h>
#include <curl/easy.h>
@@ -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