151 |
|
argv[0], argv[a]); |
152 |
|
exit(1); |
153 |
|
} |
154 |
– |
xac = a; |
154 |
|
|
155 |
< |
putchar('#'); /* simple header */ |
155 |
> |
xac = a; |
156 |
> |
/* simple header */ |
157 |
> |
putchar('#'); |
158 |
|
for (a = 0; a < xac; a++) |
159 |
|
printf(" %s", xav[a]); |
160 |
|
putchar('\n'); |
161 |
< |
|
162 |
< |
if (a == argc) |
161 |
> |
/* transform input */ |
162 |
> |
if (xac == argc) |
163 |
|
xform("standard input", stdin); |
164 |
|
else |
165 |
< |
for ( ; a < argc; a++) { |
165 |
> |
for (a = xac; a < argc; a++) { |
166 |
|
if ((fp = fopen(argv[a], "r")) == NULL) { |
167 |
|
fprintf(stderr, "%s: cannot open \"%s\"\n", |
168 |
|
progname, argv[a]); |
254 |
|
|
255 |
|
fgetline(buf, sizeof(buf), fin); |
256 |
|
if (expand) { |
257 |
< |
if ((pin = popen(buf+1, "r")) == NULL) { |
258 |
< |
fprintf(stderr, "%s: (%s): cannot execute \"%s\"\n", |
259 |
< |
progname, fname, buf); |
260 |
< |
exit(1); |
257 |
> |
if (xac > 2) { |
258 |
> |
if ((pin = popen(buf+1, "r")) == NULL) { |
259 |
> |
fprintf(stderr, |
260 |
> |
"%s: (%s): cannot execute \"%s\"\n", |
261 |
> |
progname, fname, buf); |
262 |
> |
exit(1); |
263 |
> |
} |
264 |
> |
xform(buf, pin); |
265 |
> |
pclose(pin); |
266 |
> |
} else { |
267 |
> |
fflush(stdout); |
268 |
> |
system(buf+1); |
269 |
|
} |
261 |
– |
xform(buf, pin); |
262 |
– |
pclose(pin); |
270 |
|
} else { |
271 |
< |
printf("\n%s | %s -e", buf, xav[0]); |
272 |
< |
for (i = 1; i < xac; i++) |
273 |
< |
printf(" %s", xav[i]); |
271 |
> |
printf("\n%s", buf); |
272 |
> |
if (xac > 1) { |
273 |
> |
printf(" | %s -e", xav[0]); |
274 |
> |
for (i = 1; i < xac; i++) |
275 |
> |
printf(" %s", xav[i]); |
276 |
> |
} |
277 |
|
putchar('\n'); |
278 |
|
} |
279 |
|
} |