Commit | Line | Data |
---|---|---|
f2863bc0 WD |
1 | This patch adds a --stdout=line|unbuf option that lets the |
2 | user change the buffering of stdout. | |
3 | ||
4 | To use this patch, run these commands for a successful build: | |
5 | ||
6 | patch -p1 <patches/stdout.diff | |
7 | ./configure (optional if already run) | |
8 | make | |
9 | ||
c1ff70aa | 10 | based-on: a01e3b490eb36ccf9e704840e1b6683dab867550 |
f2863bc0 WD |
11 | diff --git a/options.c b/options.c |
12 | --- a/options.c | |
13 | +++ b/options.c | |
72e5645e | 14 | @@ -301,6 +301,7 @@ static int refused_partial, refused_progress, refused_delete_before; |
f2863bc0 | 15 | static int refused_delete_during; |
85096e5e | 16 | static int refused_inplace, refused_no_iconv; |
fc557362 | 17 | static BOOL usermap_via_chown, groupmap_via_chown; |
f2863bc0 | 18 | +static char *stdout_buffering; |
5214a41b | 19 | static char *bwlimit_arg, *max_size_arg, *min_size_arg; |
f2863bc0 WD |
20 | static char tmp_partialdir[] = ".~tmp~"; |
21 | ||
72e5645e | 22 | @@ -776,6 +777,7 @@ void usage(enum logcode F) |
f2863bc0 WD |
23 | rprintf(F," --password-file=FILE read daemon-access password from FILE\n"); |
24 | rprintf(F," --list-only list the files instead of copying them\n"); | |
5214a41b | 25 | rprintf(F," --bwlimit=RATE limit socket I/O bandwidth\n"); |
f2863bc0 WD |
26 | + rprintf(F," --stdout=line|unbuf change buffering of stdout\n"); |
27 | rprintf(F," --write-batch=FILE write a batched update to FILE\n"); | |
28 | rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n"); | |
29 | rprintf(F," --read-batch=FILE read a batched update from FILE\n"); | |
72e5645e | 30 | @@ -1008,6 +1010,7 @@ static struct poptOption long_options[] = { |
f2863bc0 WD |
31 | {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 }, |
32 | {"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 }, | |
33 | {"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 }, | |
34 | + {"stdout", 0, POPT_ARG_STRING, &stdout_buffering, 0, 0, 0 }, | |
fc557362 | 35 | {"remote-option", 'M', POPT_ARG_STRING, 0, 'M', 0, 0 }, |
f2863bc0 WD |
36 | {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 }, |
37 | {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 }, | |
c1ff70aa | 38 | @@ -1793,6 +1796,13 @@ int parse_arguments(int *argc_p, const char ***argv_p) |
f2863bc0 WD |
39 | } |
40 | } | |
41 | ||
42 | + if (stdout_buffering && !am_server) { | |
43 | + if (*stdout_buffering == 'u') | |
44 | + setvbuf(stdout, NULL, _IONBF, 0); | |
45 | + else | |
46 | + setvbuf(stdout, NULL, _IOLBF, 0); | |
47 | + } | |
48 | + | |
fc557362 | 49 | if (human_readable > 1 && argc == 2 && !am_server) { |
f2863bc0 WD |
50 | /* Allow the old meaning of 'h' (--help) on its own. */ |
51 | usage(FINFO); |