ast@cs.vu.nl (Andy Tanenbaum) (02/09/89)
Some people are still using the old shar, which uses gres.
This makes it impossible to de-shar the files on UNIX machines
that do not have gres. The V1.3 shar uses sed, so these
shar files can be used on MINIX and UNIX. I would suggest
that everyone throw out their old shar and use the current
one, included below. If anyone is missing sed, send me
email and I will send it to you. (I have posted it many
times in the past, and there have been no changes to it in
at least a year or more. Its crc is:
30068 45809 minix/commands/sed.c
Andy Tanenbaum (ast@cs.vu.nl)
===================== shar.c =========================
/* shar - make a shell archive Author: Michiel Husijes */
#include <stdio.h>
#include <minix/blocksize.h>
#define IO_SIZE (10 * BLOCK_SIZE)
char input[IO_SIZE];
char output[IO_SIZE];
int ind = 0;
main(argc, argv)
int argc;
register char *argv[];
{
register int i;
int fd;
for (i = 1; i < argc; i++) {
if ((fd = open(argv[i], 0)) < 0) {
write(2, "Cannot open ", 12);
write(2, argv[i], strlen(argv[i]));
write(2, ".\n", 2);
}
else {
print("echo x - ");
print(argv[i]);
print("\nsed '/^X/s///' > ");
print(argv[i]);
print(" << '/'\n");
cat(fd);
}
}
if (ind) write(1, output, ind);
exit(0);
}
cat(fd)
int fd;
{
static char *current, *last;
register int r = 0;
register char *cur_pos = current;
putchar('X');
for (; ;) {
if (cur_pos == last) {
if ((r = read(fd, input, IO_SIZE)) <= 0)
break;
last = &input[r];
cur_pos = input;
}
putchar(*cur_pos);
if (*cur_pos++ == '\n' && cur_pos != last)
putchar('X');
}
print("/\n");
(void) close(fd);
current = cur_pos;
}
print(str)
register char *str;
{
while (*str)
putchar(*str++);
}