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
Index: fetch.1 =================================================================== 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 =================================================================== 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; - if (!v_tty || !v_level) + if (!g_flag && (!v_tty || !v_level)) return; /* check if we're the foreground process */ - if (ioctl(STDERR_FILENO, TIOCGPGRP, &ctty_pgrp) == -1 || - (pid_t)ctty_pgrp != pgrp) + if (!g_flag && (ioctl(STDERR_FILENO, TIOCGPGRP, &ctty_pgrp) == -1 || + (pid_t)ctty_pgrp != pgrp)) return; gettimeofday(&now, NULL); @@ -669,7 +670,7 @@ int c, e, r; while ((c = getopt(argc, argv, - "146AaB:bc:dFf:Hh:lMmnPpo:qRrS:sT:tUvw:")) != -1) + "146AaB:bc:dFf:gHh:lMmnPpo:qRrS:sT:tUvw:")) != -1) switch (c) { case '1': once_flag = 1; @@ -706,6 +707,9 @@ break; case 'f': f_filename = optarg; + break; + case 'g': + g_flag = 1; break; case 'H': warnx("the -H option is now implicit, "