2 * Attempt at emulation of Unix tar by calling Plan 9 tar.
4 * The differences from Plan 9 tar are:
5 * In the absence of an "f" flag, the file /dev/tape is used.
6 * An "f" flag with argument "-" causes use of stdin/stdout
7 * by passing no "f" flag (nor argument) to Plan 9 tar.
8 * By default, the "T" flag is passed to Plan 9 tar.
9 * The "m" flag to this tar inhibits this behavior.
18 fprint(2, "usage: ape/tar [crtx][vfm] [args...] [file...]\n");
23 main(int argc, char **argv)
25 int i, j, verb, vflag, fflag, Tflag, nargc;
26 char *p, *file, **nargv, *cpu, flagbuf[10], execbuf[128];
39 if(strchr("crtx", *p) == nil)
63 if(strcmp(file, "-") == 0) {
65 * plan9 doesn't know about "-" meaning stdin/stdout,
66 * but it's the default,
67 * so rewrite to not use f flag at all.
76 case 'p': /* pretend nothing's wrong */
81 nargc = 1 + 1 + fflag + argc + 1;
82 nargv = malloc(sizeof(char*) * nargc);
84 fprint(2, "ape/tar: out of memory\n");
88 cpu = getenv("cputype");
90 fprint(2, "ape/tar: need cputype environment variable set\n");
93 snprint(execbuf, sizeof execbuf, "/%s/bin/tar", cpu);
96 sprint(flagbuf, "%c%s%s%s", verb, vflag ? "v" : "", Tflag ? "T" : "", fflag ? "f" : "");
103 for(j=0; j<argc; j++, i++)
111 fprint(2, "ape/tar: fork failed: %r\n");
114 exec(execbuf, nargv);
115 fprint(2, "exec %s fails: %r\n", execbuf);
120 exits("wait failed");
121 if(w->msg[0] == '\0')