3 # MAKESHAR.sh: Make a shar file for the sources
6 AWK=/usr/bin/nawk # Must be nawk or gawk cause of 2D arrays
40 echo "$0: File `$i' not found." 1>&2
46 if [ \( -z "$files" \) -a \( -z "$dirs" \) ]
48 echo "Usage: $0 [-n name] [-s size] [-vd] <files>." 1>&2
52 $WC $files | $GREP -v total | $SORT +2 | $AWK '
71 for (maxi = i--; i >= 0; i--) {
73 if (a[i, used] == 0) {
74 if (verbose && a[i, size] > maxsize)
75 printf("Warning: File %s is %d > %d\n",
76 a[i, name], a[i, size], maxsize) > tty;
82 # Find the greatest file we can add
84 for (k = 0; k < maxi; k++)
85 if (a[k, used] == 0 && a[k, size] + s < maxsize)
97 for (i = 1; i < seq; i++) {
98 printf("shar -n%d -e%d %s ", i, seq - 1, dirs);
100 printf("%3d of %3d: ", i, seq - 1) > tty;
103 for (j = 0; kit[i, j] != -1; j++) {
104 s = a[kit[i, j], name];
106 clen = length(s) + 1;
112 printf("%s ", s) > tty;
116 printf("> '"$name"'-%d.shar;", i);
118 printf("= %5d\n", sizes[i]) > tty;