From phil@philpep.org Sun Mar 7 18:52:50 2010 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01BC51065677 for ; Sun, 7 Mar 2010 18:52:50 +0000 (UTC) (envelope-from phil@philpep.org) Received: from squat.philpep.org (trotski.philpep.org [IPv6:2001:470:1f15:7bf:dead:c0de:0:4]) by mx1.freebsd.org (Postfix) with ESMTP id B09408FC16 for ; Sun, 7 Mar 2010 18:52:49 +0000 (UTC) Received: from shen.philpep.org (shen.philpep.org [192.168.0.2]) by trotski.philpep.org (Postfix) with SMTP id A93AFACAC1 for ; Sun, 7 Mar 2010 19:52:26 +0100 (CET) Received: by shen.philpep.org (sSMTP sendmail emulation); Sun, 07 Mar 2010 19:52:48 +0100 Message-Id: <20100307185250.01BC51065677@hub.freebsd.org> Date: Sun, 07 Mar 2010 19:52:48 +0100 From: "Philippe Pepiot" Reply-To: Philippe Pepiot To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: [PATCH] bin/cp show percentage complete X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 144531 >Category: bin >Synopsis: [patch] cp(1) show percentage complete >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: suspended >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Mar 07 19:00:01 UTC 2010 >Closed-Date: >Last-Modified: Fri Oct 22 05:10:07 UTC 2010 >Originator: Philippe Pepiot >Release: FreeBSD 8.0-RELEASE-p2 i386 >Organization: >Environment: System: FreeBSD shen.philpep.org 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0 r202418: Fri Jan 15 22:29:53 CET 2010 root@shen.philpep.org:/usr/obj/usr/src/sys/SHEN i386 >Description: When use the -v (verbose) option, show progress complete. >How-To-Repeat: >Fix: --- cp-show-progress.patch begins here --- Index: utils.c =================================================================== --- utils.c (revision 204841) +++ utils.c (working copy) @@ -216,6 +216,11 @@ entp->fts_path, to.p_path, cp_pct(wtotal, fs->st_size)); } + if (vflag) + (void)fprintf(stderr, + "%s -> %s %3d%%\033[0G", + entp->fts_path, to.p_path, + cp_pct(wtotal, fs->st_size)); if (wcount >= (ssize_t)wresid) break; } Index: cp.c =================================================================== --- cp.c (revision 204841) +++ cp.c (working copy) @@ -481,7 +481,7 @@ break; } if (vflag && !badcp) - (void)printf("%s -> %s\n", curr->fts_path, to.p_path); + (void)printf("%s -> %s 100%%\n", curr->fts_path, to.p_path); } if (errno) err(1, "fts_read"); --- cp-show-progress.patch ends here --- >Release-Note: >Audit-Trail: From: Alexander Best To: bug-followup@freebsd.org Cc: Subject: Re: bin/144531: [patch] cp(1) show percentage complete Date: Tue, 24 Aug 2010 02:22:14 +0000 hi there, i don't think the original patch you submitted will be accepted by any developer since it breaks the behaviour of `cp -v`. you might want to add a new switch to trigger the extra output from your patch. just be sure you don't use any switch that's already taken by POSIX [1]. however personally i don't think that your patch will be committed even with a new switch. `cp` has been the way it is for a very long time and i don't think people want it to change. you might want to open a new thread on freebsd-hackers@ or freebsd-current@ and ask what the developers think about your patch. this might trigger some interest in this PR. the fact however is that there are a lot of PRs with great and useful additions to FreeBSD. however most people that are using FreeBSD on a daily basis don't want basic applications like `cp` to change. even if a developer would commit your patch it is most likely that he'll be forced to revert the changes due to the fact that other developers don't see the need for such a change. i would expect the argument to be something like this: "the behavior of cp hasn't change since 1977. cp didn't need this feature back then and it doesn't need it now." personally i don't agree with this point of view. good luck and i hope your patch will somehow make it into the tree. i've applied your patch to my local src tree and try to use the -v when copying large files. i really like it. :) cheers. alex [1] http://www.opengroup.org/onlinepubs/9699919799/ -- a13x State-Changed-From-To: open->suspended State-Changed-By: arundel State-Changed-When: Thu Oct 21 18:37:19 UTC 2010 State-Changed-Why: no src committer has taken any interest in this patch. there are probably a number of reasons for that: - your patch adds new functionality to a very basic UNIX application. in general those patches will almost never make it into the src tree, because people tend to consider those applications to be "perfectly designed without any need for additions" - the funcionality of your patch can be reproduced by hitting ^T during copying - alternatives to the base cp with the same or more advanced features than your patch exist in the ports collection for those reasons i'm suspending this PR. thanks a lot for your work and sorry for not attracting any committer. i highly recommend you get a few opinions from committers on freebsd-hackers@ or freebsd-current@ next time before implementing new features into long existing applications. cheers. alex http://www.freebsd.org/cgi/query-pr.cgi?pr=144531 From: jhell To: bug-followup@FreeBSD.org, phil@philpep.org Cc: Subject: Re: bin/144531: [patch] cp(1) show percentage complete Date: Fri, 22 Oct 2010 01:04:03 -0400 This is a multi-part message in MIME format. --------------060607040004000800040604 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Just for the record, I had adjusted this for local use. And while being a useful feature especially when it comes to doing simple operations such as cp(1), I also find this to be very handy as standard cp(1) does not let you see what it is actually copying until after the copy has completed. Also for the record "The -v and -n options are non-standard and their use in scripts is not recommended." I don't see a reason why there should/could not be another non-standard feature added as -v as I stated is not really useful until the actual copy of the file has completed. The local mods that I made for this patch was to make it take '-V' as a argument instead of defaulting to '-v' and adjusting the manual page to properly document it. Patch is attached for archive sake. It is a shame it couldn't be incorporated. -- jhell,v --------------060607040004000800040604 Content-Type: text/plain; name="cp-show-progress.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp-show-progress.patch" Index: bin/cp/cp.1 =================================================================== --- bin/cp/cp.1 (revision 214190) +++ bin/cp/cp.1 (working copy) @@ -45,7 +45,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i | n -.Op Fl alpvx +.Op Fl alpvVx .Ar source_file target_file .Nm .Oo @@ -53,7 +53,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i | n -.Op Fl alpvx +.Op Fl alpvVx .Ar source_file ... target_directory .Sh DESCRIPTION In the first synopsis form, the @@ -183,6 +183,11 @@ Cause .Nm to be verbose, showing files as they are copied. +.It Fl V +Cause +.Nm +to be very verbose, showing files as they are copied and printing a +percentage of its progress while copying. .It Fl x File system mount points are not traversed. .El @@ -278,6 +283,7 @@ .Pp The .Fl v +.Fl V and .Fl n options are non-standard and their use in scripts is not recommended. Index: bin/cp/utils.c =================================================================== --- bin/cp/utils.c (revision 214190) +++ bin/cp/utils.c (working copy) @@ -216,6 +216,11 @@ entp->fts_path, to.p_path, cp_pct(wtotal, fs->st_size)); } + if (vflag == 2) + (void)fprintf(stderr, + "%s -> %s %3d%%\033[0G", + entp->fts_path, to.p_path, + cp_pct(wtotal, fs->st_size)); if (wcount >= (ssize_t)wresid) break; } @@ -518,8 +523,8 @@ { (void)fprintf(stderr, "%s\n%s\n", -"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file", -" cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... " +"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvVx] source_file target_file", +" cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvVx] source_file ... " "target_directory"); exit(EX_USAGE); } Index: bin/cp/cp.c =================================================================== --- bin/cp/cp.c (revision 214190) +++ bin/cp/cp.c (working copy) @@ -103,7 +103,7 @@ fts_options = FTS_NOCHDIR | FTS_PHYSICAL; Hflag = Lflag = Pflag = 0; - while ((ch = getopt(argc, argv, "HLPRafilnprvx")) != -1) + while ((ch = getopt(argc, argv, "HLPRVafilnprvx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -151,6 +151,9 @@ case 'v': vflag = 1; break; + case 'V': + vflag = 2; + break; case 'x': fts_options |= FTS_XDEV; break; @@ -480,8 +483,10 @@ badcp = rval = 1; break; } - if (vflag && !badcp) + if (vflag == 1 && !badcp) (void)printf("%s -> %s\n", curr->fts_path, to.p_path); + if (vflag == 2 && !badcp) + (void)printf("%s -> %s 100%%\n", curr->fts_path, to.p_path); } if (errno) err(1, "fts_read"); --------------060607040004000800040604-- >Unformatted: