Hi,

I've recently started using ntfsclone in a couple of scripts. Unfortunately, the lack of any way to suppress the progress bars makes this very inconvenient, since it produces a huge amount of messy output.

This patch adds a --quiet option that turns off the progress bars. It also turns it off if it detects that the msg_out stream is not connected to a tty. The output is otherwise unchanged.

A fix to the documentation is in the works.

These changes can alternatively be pulled from the quiet_option branch at [email protected]:ligne/ntfs-3g.git

Please do not hesitate to comment if you have any issues. But hopefully this should all be fairly uncontroversial stuff :-)

Regards,

--Matt


--
Matthew Boyle, Systems Administrator, CoreFiling Limited
Telephone: +44-1865-203192  Website: http://www.corefiling.com
diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c
index 7d56cc6..b60120f 100644
--- a/ntfsprogs/ntfsclone.c
+++ b/ntfsprogs/ntfsclone.c
@@ -337,6 +337,7 @@ static void parse_options(int argc, char **argv)
 #ifdef DEBUG
                { "debug",            no_argument,       NULL, 'd' },
 #endif
+               { "quiet",            no_argument,       NULL, 'q' },
                { "force",            no_argument,       NULL, 'f' },
                { "help",             no_argument,       NULL, 'h' },
                { "metadata",         no_argument,       NULL, 'm' },
@@ -364,6 +365,9 @@ static void parse_options(int argc, char **argv)
                case 'd':
                        opt.debug++;
                        break;
+               case 'q':
+                       opt.quiet++;
+                       break;
                case 'f':
                        opt.force++;
                        break;
@@ -499,6 +503,9 @@ static void progress_update(struct progress_bar *p, u64 
current)
 {
        float percent = p->unit * current;
 
+       if (opt.quiet)
+               return;
+
        if (current != p->stop) {
                if ((current - p->start) % p->resolution)
                        return;
@@ -1951,6 +1958,12 @@ int main(int argc, char **argv)
 
        parse_options(argc, argv);
 
+#ifdef HAVE_UNISTD_H
+       /* avoid showing a progress-bar unless it's being sent to a terminal */
+       if (!isatty(fileno(msg_out)))
+               opt.quiet++;
+#endif
+
        utils_set_locale();
 
        if (opt.restore_image) {
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
ntfs-3g-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel

Reply via email to