2 * Copyright (c) 2021, 2022 Omar Polo <op@omarpolo.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/ioctl.h>
20 #include <sys/types.h>
21 #include <sys/socket.h>
41 #include <readline/readline.h>
42 #include <readline/history.h>
46 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
54 #define TMPFSTR "/tmp/kamiftp.XXXXXXXXXX"
55 #define TMPFSTRLEN sizeof(TMPFSTR)
67 struct tls_config *tlsconf;
71 struct evbuffer *dirbuf;
75 volatile sig_atomic_t resized;
87 #define ASSERT_EMPTYBUF() assert(EVBUFFER_LENGTH(buf) == 0)
91 readline(const char *prompt)
93 char *ch, *line = NULL;
100 linelen = getline(&line, &linesize, stdin);
104 if ((ch = strchr(line, '\n')) != NULL)
110 add_history(const char *line)
117 read_line(const char *prompt)
122 if ((line = readline(prompt)) == NULL)
124 /* XXX: trim spaces? */
135 spawn(const char *argv0, ...)
140 const char *argv[16], *last;
143 memset(argv, 0, sizeof(argv));
147 for (i = 1; i < nitems(argv); ++i) {
148 last = va_arg(ap, const char *);
155 assert(last == NULL);
157 switch (pid = fork()) {
161 execvp(argv[0], (char *const *)argv);
164 waitpid(pid, &status, 0);
169 tty_resized(int signo)
177 fprintf(stderr, "usage: %s [-c] [-C cert] [-K key] "
178 "host[:port] [path]\n", getprogname());
179 fprintf(stderr, "kamid suite version " KAMID_VERSION "\n");
202 hexdump("outgoing message", EVBUFFER_DATA(evb),
203 EVBUFFER_LENGTH(evb));
205 while (EVBUFFER_LENGTH(evb) != 0) {
206 buf = EVBUFFER_DATA(evb);
207 nbytes = EVBUFFER_LENGTH(evb);
210 r = write(sock, buf, nbytes);
211 if (r == 0 || r == -1)
214 r = tls_write(ctx, buf, nbytes);
215 if (r == TLS_WANT_POLLIN || r == TLS_WANT_POLLOUT)
218 errx(1, "tls: %s", tls_error(ctx));
221 evbuffer_drain(evb, r);
226 mustread(void *d, size_t len)
232 r = read(sock, d, len);
233 if (r == 0 || r == -1)
236 r = tls_read(ctx, d, len);
237 if (r == TLS_WANT_POLLIN || r == TLS_WANT_POLLOUT)
240 errx(1, "tls: %s", tls_error(ctx));
254 mustread(&len, sizeof(len));
256 if (len < HEADERSIZE)
257 errx(1, "read message of invalid length %d", len);
259 len -= 4; /* skip the length just read */
262 l = MIN(len, sizeof(tmp));
265 evbuffer_add(buf, tmp, l);
269 hexdump("incoming packet", EVBUFFER_DATA(buf),
270 EVBUFFER_LENGTH(buf));
274 np_read64(struct evbuffer *buf)
278 evbuffer_remove(buf, &n, sizeof(n));
283 np_read32(struct evbuffer *buf)
287 evbuffer_remove(buf, &n, sizeof(n));
292 np_read16(struct evbuffer *buf)
296 evbuffer_remove(buf, &n, sizeof(n));
301 np_read8(struct evbuffer *buf)
305 evbuffer_remove(buf, &n, sizeof(n));
310 np_readstr(struct evbuffer *buf)
315 len = np_read16(buf);
316 assert(EVBUFFER_LENGTH(buf) >= len);
318 if ((str = calloc(1, len+1)) == NULL)
320 evbuffer_remove(buf, str, len);
325 np_read_qid(struct evbuffer *buf, struct qid *qid)
327 assert(EVBUFFER_LENGTH(buf) >= QIDSIZE);
329 qid->type = np_read8(buf);
330 qid->vers = np_read32(buf);
331 qid->path = np_read64(buf);
335 np_read_stat(struct evbuffer *buf, struct np_stat *st)
339 memset(st, 0, sizeof(*st));
341 size = np_read16(buf);
342 if (size > EVBUFFER_LENGTH(buf))
345 st->type = np_read16(buf);
346 st->dev = np_read32(buf);
347 np_read_qid(buf, &st->qid);
348 st->mode = np_read32(buf);
349 st->atime = np_read32(buf);
350 st->mtime = np_read32(buf);
351 st->length = np_read64(buf);
352 st->name = np_readstr(buf);
353 st->uid = np_readstr(buf);
354 st->gid = np_readstr(buf);
355 st->muid = np_readstr(buf);
375 err = np_readstr(buf);
376 errx(1, "expected %s, got error %s",
377 pp_msg_type(type), err);
380 errx(1, "expected %s, got msg type %s",
381 pp_msg_type(type), pp_msg_type(t));
385 expect2(uint8_t type, uint16_t tag)
395 errx(1, "expected tag 0x%x, got 0x%x", tag, t);
399 check(uint8_t type, uint16_t tag)
404 rtype = np_read8(buf);
405 rtag = np_read16(buf);
408 errx(1, "expected tag 0x%x, got 0x%x", tag, rtag);
413 return np_readstr(buf);
415 errx(1, "expected %s, got msg type %s",
416 pp_msg_type(type), pp_msg_type(rtype));
424 tversion(VERSION9P, MSIZE9P);
427 expect2(Rversion, NOTAG);
429 msize = np_read32(buf);
430 version = np_readstr(buf);
432 if (msize > MSIZE9P || msize < 256)
433 errx(1, "got unexpected msize: %d", msize);
434 if (strcmp(version, VERSION9P))
435 errx(1, "unexpected 9p version: %s", version);
442 do_attach(const char *path)
449 tattach(pwdfid, NOFID, user, path);
452 expect2(Rattach, iota_tag);
453 np_read_qid(buf, &qid);
459 do_open(uint32_t fid, uint8_t mode)
467 expect2(Ropen, iota_tag);
469 np_read_qid(buf, &qid);
470 iounit = np_read32(buf);
478 do_create(uint32_t fid, const char *name, uint32_t perm, uint8_t mode)
483 tcreate(fid, name, perm, mode);
486 expect2(Rcreate, iota_tag);
488 np_read_qid(buf, &qid);
489 iounit = np_read32(buf);
497 do_clunk(uint32_t fid)
502 expect2(Rclunk, iota_tag);
508 dup_fid(int fid, int nfid)
513 twalk(fid, nfid, NULL, 0);
517 if ((errstr = check(Rwalk, iota_tag)) != NULL)
520 nwqid = np_read16(buf);
529 walk_path(int fid, int newfid, const char *path, int *missing,
532 char *wnames[MAXWELEM], *p, *t, *errstr;
536 if ((p = strdup(path)) == NULL)
540 /* strip initial ./ */
541 if (t[0] == '.' && t[1] == '/')
544 for (nwname = 0; nwname < nitems(wnames) &&
545 (wnames[nwname] = strsep(&t, "/")) != NULL;) {
546 if (*wnames[nwname] != '\0')
550 twalk(fid, newfid, (const char **)wnames, nwname);
555 if ((errstr = check(Rwalk, iota_tag)) != NULL) {
560 nwqid = np_read16(buf);
561 assert(nwqid <= nwname);
563 /* consume all qids */
564 for (i = 0; i < nwqid; ++i)
565 np_read_qid(buf, qid);
569 *missing = nwname - nwqid;
574 do_stat(int fid, struct np_stat *st)
579 expect2(Rstat, iota_tag);
581 /* eat up the first two byte length */
584 if (np_read_stat(buf, st) == -1)
585 errx(1, "invalid stat struct read");
591 do_wstat(int fid, const struct np_stat *st)
599 if ((errstr = check(Rwstat, iota_tag)) != NULL)
608 do_read(int fid, uint64_t off, uint32_t count, void *data)
612 tread(fid, off, count);
615 expect2(Rread, iota_tag);
618 assert(r == EVBUFFER_LENGTH(buf));
620 evbuffer_remove(buf, data, r);
628 do_write(int fid, uint64_t off, uint32_t count, void *data)
632 twrite(fid, off, data, count);
635 expect2(Rwrite, iota_tag);
646 draw_progress(const char *pre, const struct progress *p)
655 perc = 100.0 * p->done / p->max;
657 fprintf(stderr, "%s: %d%%\n", pre, (int)perc);
664 if (ioctl(0, TIOCGWINSZ, &ws) == -1)
666 tty_width = ws.ws_col;
671 ((l = printf("\r%s ", pre)) == -1 || l >= w))
674 w -= l + 2 + 5; /* 2 for |, 5 for percentage + \n */
676 printf("%4d%%\n", (int)perc);
682 l = w * MIN(100.0, perc) / 100.0;
683 for (i = 0; i < l; i++)
687 printf("|%4d%%", (int)perc);
693 fetch_fid(int fid, int fd, const char *name)
695 static char buf[MSIZE9P];
696 struct progress p = {0};
702 do_open(fid, KOREAD);
709 len = MIN(sizeof(buf), msize);
710 len -= IOHDRSZ; /* for the request' fields */
712 r = do_read(fid, p.done, len, buf);
716 for (off = 0; off < r; off += nw)
717 if ((nw = write(fd, buf + off, r - off)) == 0 ||
724 draw_progress(name, &p);
727 /* throttle, for debugging purpose */
729 struct timespec ts = { 0, 500000000 };
730 nanosleep(&ts, NULL);
743 send_fid(int fid, const char *fnam, int open_flags, int fd, const char *name)
745 static char buf[MSIZE9P];
746 struct progress p = {0};
751 if (fstat(fd, &sb) == -1)
755 do_create(fid, fnam, 0644, KOWRITE);
757 do_open(fid, open_flags | KOWRITE);
761 len = MIN(sizeof(buf), msize);
762 len -= HEADERSIZE + 4 + 4 + 8; /* for the request' fields */
764 r = read(fd, buf, len);
770 w = do_write(fid, p.done, r, buf);
773 draw_progress(name, &p);
776 /* throttle, for debugging purpose */
778 struct timespec ts = { 0, 500000000 };
779 nanosleep(&ts, NULL);
789 woc_file(int fd, const char *prompt, const char *path)
792 const char *n = NULL;
797 errstr = walk_path(pwdfid, nfid, path, &miss, &qid);
798 if (errstr != NULL && miss > 1) {
799 printf("%s: %s\n", path, errstr);
804 if (errstr != NULL || miss == 1) {
805 char p[PATH_MAX], *dn;
808 * If it's only one component missing (the file name), walk
809 * to the parent directory and try to create the file.
812 if (strlcpy(p, path, sizeof(p)) >= sizeof(p)) {
813 printf("path too long: %s\n", path);
818 if (!strcmp(dn, ".")) {
819 errstr = dup_fid(pwdfid, nfid);
822 errstr = walk_path(pwdfid, nfid, dn, &miss, &qid);
824 if (errstr != NULL) {
825 printf("%s: %s\n", dn, errstr);
831 printf("%s: not a directory\n", dn);
835 if ((n = strrchr(path, '/')) != NULL)
844 printf("can't create %s: missing %d path component(s)\n",
849 send_fid(nfid, n, KOTRUNC, fd, prompt);
854 do_tls_connect(const char *host, const char *port)
858 if ((tlsconf = tls_config_new()) == NULL)
859 fatalx("tls_config_new");
860 tls_config_insecure_noverifycert(tlsconf);
861 tls_config_insecure_noverifyname(tlsconf);
866 if (tls_config_set_keypair_file(tlsconf, crtpath, keypath) == -1)
867 fatalx("can't load certs (%s, %s)", crtpath, keypath);
869 if ((ctx = tls_client()) == NULL)
871 if (tls_configure(ctx, tlsconf) == -1)
872 fatalx("tls_configure: %s", tls_error(ctx));
874 if (tls_connect(ctx, host, port) == -1)
875 fatalx("can't connect to %s:%s: %s", host, port,
878 for (handshake = 0; !handshake;) {
879 switch (tls_handshake(ctx)) {
881 fatalx("tls_handshake: %s", tls_error(ctx));
890 do_ctxt_connect(const char *host, const char *port)
892 struct addrinfo hints, *res, *res0;
893 int error, saved_errno;
894 const char *cause = NULL;
896 memset(&hints, 0, sizeof(hints));
897 hints.ai_family = AF_UNSPEC;
898 hints.ai_socktype = SOCK_STREAM;
899 error = getaddrinfo(host, port, &hints, &res0);
901 errx(1, "%s", gai_strerror(error));
904 for (res = res0; res != NULL; res = res->ai_next) {
905 sock = socket(res->ai_family, res->ai_socktype|SOCK_CLOEXEC,
912 if (connect(sock, res->ai_addr, res->ai_addrlen) == -1) {
930 do_connect(const char *connspec, const char *path)
935 host = xstrdup(connspec);
936 if ((t = strchr(host, '@')) != NULL) {
938 errx(1, "invalid connection string: %s", connspec);
942 } else if ((user = getenv("USER")) == NULL)
943 errx(1, "USER not defined");
945 if ((t = strchr(host, ':')) != NULL) {
949 errx(1, "invalid connection string: %s", connspec);
953 printf("connecting to %s:%s...", host, port);
957 do_tls_connect(host, port);
959 do_ctxt_connect(host, port);
968 tmp_file(char sfn[TMPFSTRLEN])
972 strlcpy(sfn, TMPFSTR, TMPFSTRLEN);
973 if ((tmpfd = mkstemp(sfn)) == -1) {
974 warn("mkstemp %s", sfn);
978 /* set the close-on-exec flag */
979 if (fcntl(tmpfd, F_SETFD, FD_CLOEXEC) == -1) {
988 static inline const char *
1009 /* unreachable, just for the compiler' happiness */
1015 prepare_wstat(struct np_stat *st)
1017 memset(st, 0xFF, sizeof(*st));
1025 cmd_bell(int argc, const char **argv)
1030 puts("bell mode enabled");
1032 puts("bell mode disabled");
1039 if (!strcmp(*argv, "on")) {
1041 puts("bell mode enabled");
1045 if (!strcmp(*argv, "off")) {
1047 puts("bell mode disabled");
1052 printf("bell [on | off]\n");
1056 cmd_bye(int argc, const char **argv)
1063 cmd_cd(int argc, const char **argv)
1070 printf("usage: cd remote-path\n");
1075 errstr = walk_path(pwdfid, nfid, argv[0], &miss, &qid);
1076 if (errstr != NULL) {
1077 printf("%s: %s\n", argv[0], errstr);
1082 if (miss != 0 || !(qid.type & QTDIR)) {
1083 printf("%s: not a directory\n", argv[0]);
1094 cmd_edit(int argc, const char **argv)
1097 int nfid, tmpfd, miss;
1098 char sfn[TMPFSTRLEN], p[PATH_MAX], *name, *errstr;
1102 puts("usage: edit file");
1106 if ((ed = getenv("VISUAL")) == NULL &&
1107 (ed = getenv("EDITOR")) == NULL)
1111 errstr = walk_path(pwdfid, nfid, *argv, &miss, &qid);
1112 if (errstr != NULL) {
1113 printf("%s: %s\n", *argv, errstr);
1118 if (miss != 0 || qid.type != 0) {
1119 printf("%s: not a file\n", *argv);
1125 if ((tmpfd = tmp_file(sfn)) == -1) {
1130 strlcpy(p, *argv, sizeof(p));
1133 if (fetch_fid(nfid, tmpfd, name)) {
1134 warn("failed fetch or can't write %s", sfn);
1139 spawn(ed, sfn, NULL);
1142 * Re-open the file because it's not guaranteed that the
1143 * file descriptor tmpfd is still associated with the file
1144 * pointed by sfn: it's not uncommon for editor to write
1145 * a backup file and then rename(2) it to the file name.
1147 if ((tmpfd = open(sfn, O_RDONLY)) == -1) {
1148 warn("can't open %s", sfn);
1152 woc_file(tmpfd, *argv, name);
1160 cmd_get(int argc, const char **argv)
1167 if (argc != 1 && argc != 2) {
1168 printf("usage: get remote-file [local-file]\n");
1174 else if ((l = strrchr(argv[0], '/')) != NULL)
1180 errstr = walk_path(pwdfid, nfid, argv[0], &miss, &qid);
1181 if (errstr != NULL) {
1182 printf("%s: %s\n", argv[0], errstr);
1187 if (miss != 0 || qid.type != 0) {
1188 printf("%s: not a file\n", argv[0]);
1194 if ((fd = open(l, O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0644)) == -1) {
1195 warn("can't open %s", l);
1200 if (fetch_fid(nfid, fd, l) == -1)
1201 warn("write %s", l);
1206 cmd_hexdump(int argc, const char **argv)
1211 puts("hexdump mode enabled");
1213 puts("hexdump mode disabled");
1220 if (!strcmp(*argv, "on")) {
1222 puts("hexdump mode enabled");
1226 if (!strcmp(*argv, "off")) {
1228 puts("hexdump mode disabled");
1233 puts("usage: hexdump [on | off]");
1237 cmd_lcd(int argc, const char **argv)
1242 printf("usage: lcd [local-directory]\n");
1249 if (argc == 0 && (dir = getenv("HOME")) == NULL) {
1250 printf("HOME is not defined\n");
1254 if (chdir(dir) == -1)
1255 printf("cd: %s: %s\n", dir, strerror(errno));
1259 cmd_lpwd(int argc, const char **argv)
1261 char path[PATH_MAX];
1264 printf("usage: lpwd\n");
1268 if (getcwd(path, sizeof(path)) == NULL) {
1269 printf("lpwd: %s\n", strerror(errno));
1273 printf("%s\n", path);
1277 cmd_ls(int argc, const char **argv)
1286 char fmt[FMT_SCALED_STRSIZE], tim[13], *errstr;
1289 printf("ls don't take arguments (yet)\n");
1296 if ((errstr = dup_fid(pwdfid, nfid)) != NULL) {
1297 printf(".: %s\n", errstr);
1302 do_open(nfid, KOREAD);
1304 evbuffer_drain(dirbuf, EVBUFFER_LENGTH(dirbuf));
1307 tread(nfid, off, msize - IOHDRSZ);
1310 expect2(Rread, iota_tag);
1312 len = np_read32(buf);
1316 evbuffer_add_buffer(dirbuf, buf);
1322 while (EVBUFFER_LENGTH(dirbuf) != 0) {
1323 if (np_read_stat(dirbuf, &st) == -1)
1324 errx(1, "invalid stat struct read");
1326 if (fmt_scaled(st.length, fmt) == -1)
1327 strlcpy(fmt, "xxx", sizeof(fmt));
1331 if (now > mtime && (now - mtime) < 365/2 * 24 * 12 * 60)
1332 timfmt = "%b %e %R";
1334 timfmt = "%b %e %Y";
1336 if ((tm = localtime(&mtime)) == NULL ||
1337 strftime(tim, sizeof(tim), timfmt, tm) == 0)
1338 strlcpy(tim, "unknown", sizeof(tim));
1340 if (st.qid.type & QTDIR)
1344 printf("%s", pp_perm(st.mode >> 6));
1345 printf("%s", pp_perm(st.mode >> 3));
1346 printf("%s", pp_perm(st.mode));
1347 printf(" %8s %12s %s%s\n", fmt, tim, st.name,
1348 st.qid.type & QTDIR ? "/" : "");
1360 cmd_page(int argc, const char **argv)
1363 int nfid, tmpfd, miss, r;
1364 char sfn[TMPFSTRLEN], p[PATH_MAX], *name, *errstr;
1368 puts("usage: page file");
1372 if ((pager = getenv("PAGER")) == NULL)
1376 errstr = walk_path(pwdfid, nfid, *argv, &miss, &qid);
1377 if (errstr != NULL) {
1378 printf("%s: %s\n", *argv, errstr);
1383 if (miss != 0 || qid.type != 0) {
1384 printf("%s: not a file\n", *argv);
1390 if ((tmpfd = tmp_file(sfn)) == -1) {
1395 strlcpy(p, *argv, sizeof(p));
1397 if ((r = fetch_fid(nfid, tmpfd, name)) == -1)
1398 warn("write %s", sfn);
1401 spawn(pager, sfn, NULL);
1406 cmd_pipe(int argc, const char **argv)
1410 int nfid, tmpfd, miss, status;
1411 int filedes[2]; /* read end, write end */
1415 puts("usage: pipe remote-file cmd [args...]");
1420 errstr = walk_path(pwdfid, nfid, *argv, &miss, &qid);
1421 if (errstr != NULL) {
1422 printf("%s: %s\n", *argv, errstr);
1427 if (miss != 0 || qid.type != 0) {
1428 printf("%s: not a file\n", *argv);
1434 if (pipe(filedes) == -1)
1437 switch (pid = vfork()) {
1442 if (dup2(filedes[0], 0) == -1)
1444 execvp(argv[1], (char *const *)argv + 1);
1449 if (fetch_fid(nfid, filedes[1], *argv) == -1)
1450 warnx("failed to fetch all the file");
1453 waitpid(pid, &status, 0);
1457 cmd_put(int argc, const char **argv)
1463 if (argc != 1 && argc != 2) {
1464 printf("usage: put local-file [remote-file]\n");
1470 else if ((l = strrchr(argv[0], '/')) != NULL)
1475 if ((fd = open(argv[0], O_RDONLY)) == -1) {
1476 warn("%s", argv[0]);
1480 woc_file(fd, argv[0], l);
1485 cmd_rename(int argc, const char **argv)
1493 puts("usage: rename remote-file new-remote-name");
1498 errstr = walk_path(pwdfid, nfid, argv[0], &miss, &qid);
1499 if (errstr != NULL) {
1500 printf("%s: %s\n", argv[0], errstr);
1506 printf("%s: not such file or directory\n", argv[0]);
1511 st.name = (char *)argv[1];
1512 if ((errstr = do_wstat(nfid, &st)) != NULL) {
1513 printf("rename: %s\n", errstr);
1521 cmd_verbose(int argc, const char **argv)
1524 log_setverbose(!log_getverbose());
1525 if (log_getverbose())
1526 puts("verbose mode enabled");
1528 puts("verbose mode disabled");
1535 if (!strcmp(*argv, "on")) {
1537 puts("verbose mode enabled");
1541 if (!strcmp(*argv, "off")) {
1543 puts("verbose mode disabled");
1548 printf("verbose [on | off]\n");
1552 excmd(int argc, const char **argv)
1556 void (*fn)(int, const char **);
1563 {"hexdump", cmd_hexdump},
1571 {"rename", cmd_rename},
1572 {"verbose", cmd_verbose},
1578 for (i = 0; i < nitems(cmds); ++i) {
1579 if (!strcmp(cmds[i].name, *argv)) {
1580 cmds[i].fn(argc-1, argv+1);
1585 log_warnx("unknown command %s", *argv);
1589 main(int argc, char **argv)
1593 log_init(1, LOG_DAEMON);
1595 log_procinit(getprogname());
1597 while ((ch = getopt(argc, argv, "C:cK:")) != -1) {
1617 if (argc == 0 || (tls && crtpath == NULL))
1620 signal(SIGPIPE, SIG_IGN);
1624 signal(SIGWINCH, tty_resized);
1627 if ((evb = evbuffer_new()) == NULL)
1628 fatal("evbuffer_new");
1630 if ((buf = evbuffer_new()) == NULL)
1631 fatal("evbuffer_new");
1633 if ((dirbuf = evbuffer_new()) == NULL)
1634 fatal("evbuferr_new");
1636 do_connect(argv[0], argv[1]);
1640 char *line, *argv[16] = {0}, **ap;
1642 if ((line = read_line("kamiftp> ")) == NULL)
1645 for (argc = 0, ap = argv; ap < &argv[15] &&
1646 (*ap = strsep(&line, " \t")) != NULL;) {
1650 excmd(argc, (const char **)argv);