summaryrefslogtreecommitdiff
path: root/news/knews/patches/patch-bg
blob: 76d8a9a0e6ca664bacff7461c3fddb5ee0376466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$NetBSD: patch-bg,v 1.1 2001/08/15 06:09:02 fredb Exp $

--- src/save.c.orig	Sun Jul  8 08:31:37 2001
+++ src/save.c
@@ -9,6 +9,7 @@
 #include "child.h"
 #include "codes.h"
 #include "connect.h"
+#include "expand.h"
 #include "file.h"
 #include "save.h"
 #include "sysdeps.h"
@@ -256,6 +257,9 @@
 	char	*buffer;
 	SERVER	*server;
 
+	sprintf(p, "%ld of %ld", i + 1, n);
+	set_message(message, False);
+
 	server = cache_get_server(arts[i]->no, False);
 	if (!server) {
 	    char	command[32];
@@ -276,9 +280,6 @@
 	    server_free(server);
 	else if (!buffer)
 	    return -1;
-
-	sprintf(p, "%ld", i + 1);
-	set_message(message, False);
     }
 
     if (fflush(fp) < 0)
@@ -436,7 +437,7 @@
     XtFree(cmd);
 }
 
-static void do_pipe(char *command, SaveScope scope, int what)
+static void do_pipe(char *raw_command, SaveScope scope, int what)
 {
     FILE	*file = NULL;
     char	*file_name;
@@ -445,6 +446,7 @@
     int		status, fflush_status;
     char	message[128];
     pid_t	pid;
+    char	*command;
     char	*temp;
 
     if (global.busy)
@@ -453,11 +455,17 @@
     if (global.mode != NewsModeGroup &&	global.mode != NewsModeThread) {
 	set_message("Not in a newsgroup!", True);
 	return;
-    } else if (!command || command[0] == '\0') {
+    } else if (!raw_command || raw_command[0] == '\0') {
 	set_message("No command specified!", True);
 	return;
     } else if (!(what & (SAVE_HEAD | SAVE_BODY))) {
 	set_message("Nothing to pipe (neither head or body selected)!", True);
+	return;
+    }
+
+    command = expand_save_text(raw_command);
+    if (!command) {
+	set_message("Shell command expansion failed!", True);
 	return;
     }