git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sparsify: Add auto-detection of .vdi files.
[libguestfs.git]
/
fish
/
progress.c
diff --git
a/fish/progress.c
b/fish/progress.c
index
623dd0e
..
b812a57
100644
(file)
--- a/
fish/progress.c
+++ b/
fish/progress.c
@@
-13,7
+13,7
@@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139,
USA.
+ * Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA.
*/
#include <config.h>
*/
#include <config.h>
@@
-92,6
+92,7
@@
struct progress_bar {
struct rmsd rmsd; /* running mean and standard deviation */
int have_terminfo;
int utf8_mode;
struct rmsd rmsd; /* running mean and standard deviation */
int have_terminfo;
int utf8_mode;
+ int machine_readable;
};
struct progress_bar *
};
struct progress_bar *
@@
-104,14
+105,22
@@
progress_bar_init (unsigned flags)
if (bar == NULL)
return NULL;
if (bar == NULL)
return NULL;
- bar->utf8_mode = STREQ (nl_langinfo (CODESET), "UTF-8");
+ if (flags & PROGRESS_BAR_MACHINE_READABLE) {
+ bar->machine_readable = 1;
+ bar->utf8_mode = 0;
+ bar->have_terminfo = 0;
+ } else {
+ bar->machine_readable = 0;
+
+ bar->utf8_mode = STREQ (nl_langinfo (CODESET), "UTF-8");
- bar->have_terminfo = 0;
+
bar->have_terminfo = 0;
- term = getenv ("TERM");
- if (term) {
- if (tgetent (NULL, term) == 1)
- bar->have_terminfo = 1;
+ term = getenv ("TERM");
+ if (term) {
+ if (tgetent (NULL, term) == 1)
+ bar->have_terminfo = 1;
+ }
}
/* Call this to ensure the other fields are in a reasonable state.
}
/* Call this to ensure the other fields are in a reasonable state.
@@
-257,13
+266,7
@@
progress_bar_set (struct progress_bar *bar,
double ratio;
const char *s_open, *s_dot, *s_dash, *s_close;
double ratio;
const char *s_open, *s_dot, *s_dash, *s_close;
- if (bar->utf8_mode) {
- s_open = "\u27e6"; s_dot = "\u2589"; s_dash = "\u2550"; s_close = "\u27e7";
- } else {
- s_open = "["; s_dot = "#"; s_dash = "-"; s_close = "]";
- }
-
- if (bar->have_terminfo == 0) {
+ if (bar->machine_readable || bar->have_terminfo == 0) {
dumb:
printf ("%" PRIu64 "/%" PRIu64 "\n", position, total);
} else {
dumb:
printf ("%" PRIu64 "/%" PRIu64 "\n", position, total);
} else {
@@
-292,6
+295,15
@@
progress_bar_set (struct progress_bar *bar,
fputs (" 100% ", stdout);
}
fputs (" 100% ", stdout);
}
+ if (bar->utf8_mode) {
+ s_open = "\u27e6";
+ s_dot = "\u2593";
+ s_dash = "\u2550";
+ s_close = "\u27e7";
+ } else {
+ s_open = "["; s_dot = "#"; s_dash = "-"; s_close = "]";
+ }
+
fputs (s_open, stdout);
if (!pulse_mode) {
fputs (s_open, stdout);
if (!pulse_mode) {
@@
-342,4
+354,5
@@
progress_bar_set (struct progress_bar *bar,
fputc ('\n', stdout);
}
fputc ('\n', stdout);
}
+ fflush (stdout);
}
}