Skip site navigation (1)Skip section navigation (2)
Date:      04 Nov 2002 12:54:22 -0600
From:      Craig Boston <craig@gjgth.gank.org>
To:        current@freebsd.org
Subject:   Patch for fetch
Message-ID:  <1036436066.94641.130.camel@owen1492.it.oot>

next in thread | raw e-mail | index | archive | help

--=-15TnTTgUC2wpVei0VopM
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

The attached is a quick patch for fetch(1).  It adds a new option (-g)
that forces the transfer progress to be printed, even if it thinks that
stderr is not a tty or that it is not the foreground process.

This is useful for me in a program that runs "make fetch" in a port
directory through a pipe and wants to keep tabs on the download
progress.  Modifying fetch seemed to be the simplest and most
straightforward of all my options; rather than requiring wget or
re-implementing some of make's logic.

Hopefully this will be useful to someone in a similar situation.

Craig Boston

--=-15TnTTgUC2wpVei0VopM
Content-Disposition: attachment; filename=fetch.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=fetch.patch; charset=ISO-8859-1

Index: fetch.1
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.bin/fetch/fetch.1,v
retrieving revision 1.48
diff -u -r1.48 fetch.1
--- fetch.1	2002/04/19 23:35:12	1.48
+++ fetch.1	2002/11/04 16:39:37
@@ -102,6 +102,8 @@
 on the remote host.
 This option is deprecated and is provided for backward compatibility
 only.
+.It Fl g
+Force output of transfer progress even if stderr is not a tty.
 .It Fl h Ar host
 The file to retrieve is located on the host
 .Ar host .
Index: fetch.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/src/usr.bin/fetch/fetch.c,v
retrieving revision 1.54
diff -u -r1.54 fetch.c
--- fetch.c	2002/10/27 17:33:08	1.54
+++ fetch.c	2002/11/04 16:39:37
@@ -58,6 +58,7 @@
 int	 d_flag;	/*    -d: direct connection */
 int	 F_flag;	/*    -F: restart without checking mtime  */
 char	*f_filename;	/*    -f: file to fetch */
+int	 g_flag;	/*    -g: force progress output */
 char	*h_hostname;	/*    -h: host to fetch from */
 int	 l_flag;	/*    -l: link rather than copy file: URLs */
 int	 m_flag;	/* -[Mm]: mirror mode */
@@ -128,12 +129,12 @@
 	struct timeval now;
 	int ctty_pgrp;
=20
-	if (!v_tty || !v_level)
+	if (!g_flag && (!v_tty || !v_level))
 		return;
=20
 	/* check if we're the foreground process */
-	if (ioctl(STDERR_FILENO, TIOCGPGRP, &ctty_pgrp) =3D=3D -1 ||
-	    (pid_t)ctty_pgrp !=3D pgrp)
+	if (!g_flag && (ioctl(STDERR_FILENO, TIOCGPGRP, &ctty_pgrp) =3D=3D -1 ||
+	    (pid_t)ctty_pgrp !=3D pgrp))
 		return;
=20
 	gettimeofday(&now, NULL);
@@ -669,7 +670,7 @@
 	int c, e, r;
=20
 	while ((c =3D getopt(argc, argv,
-	    "146AaB:bc:dFf:Hh:lMmnPpo:qRrS:sT:tUvw:")) !=3D -1)
+	    "146AaB:bc:dFf:gHh:lMmnPpo:qRrS:sT:tUvw:")) !=3D -1)
 		switch (c) {
 		case '1':
 			once_flag =3D 1;
@@ -706,6 +707,9 @@
 			break;
 		case 'f':
 			f_filename =3D optarg;
+			break;
+		case 'g':
+			g_flag =3D 1;
 			break;
 		case 'H':
 			warnx("the -H option is now implicit, "

--=-15TnTTgUC2wpVei0VopM--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1036436066.94641.130.camel>