1 /* shar - make a shell archive Author: Michiel Husijes */
6 static void error(char *progname
, char *operation
, char *filename
);
7 int main(int argc
, char **argv
);
20 for (argn
= 1; argn
< argc
; argn
++) {
21 filename
= argv
[argn
];
22 if ((fp
= fopen(filename
, "r")) == NULL
) {
23 error(argv
[0], "opening ", filename
);
26 fputs("echo x - ", stdout
);
27 fputs(filename
, stdout
);
28 fputs("\nsed '/^X/s///' > ", stdout
);
29 fputs(filename
, stdout
);
30 fputs(" << '/'\n", stdout
);
31 while ((ch
= getc(fp
)) != EOF
) {
43 error(argv
[0], "reading ", filename
);
46 if (fclose(fp
) != 0) {
47 error(argv
[0], "closing ", filename
);
50 if (ferror(stdout
)) break; /* lost already */
55 error(argv
[0], "writing ", "stdout");
61 static void error(progname
, operation
, filename
)
66 fputs(progname
, stderr
);
67 fputs(": error ", stderr
);
68 fputs(operation
, stderr
);