Commits

Anonymous committed 82b5c11

make -t term actually work

Comments (0)

Files changed (1)

 
 	if ((wins[wd] = fork()) == 0) {
 		execvp(wincmd[0], wincmd);
-		err(1, "failed on execlp cw");
+		err(1, "failed on execvp %s", term);
 	}
 }
 
 		if (argv[i][2] != '\0')
 			usage();
 		switch (argv[i][1]) {
-			case 't' : if (i + 1 >= argc) usage(); strncpy(term, argv[i + 1], sizeof(term)); break;
+			case 't' : if (i + 1 >= argc) usage(); strncpy(term, argv[++i], sizeof(term)); break;
 			case 'v' : printf("pcw-"VERSION" © Evan Gates\n"); exit(1);
 			default  : usage();
 		}
 	if (i >= argc)
 		usage();
 
-	if (stat(argv[1], &st) < 0 || !S_ISDIR(st.st_mode))
-		errx(1, "%s does not exist or is not a directory", argv[1]);
+	if (stat(argv[i], &st) < 0 || !S_ISDIR(st.st_mode))
+		errx(1, "%s does not exist or is not a directory", argv[i]);
 
 	if (signal(SIGCHLD, sigchld) == SIG_ERR)
 		err(1, "failed installing SIGCHLD handler");
 		err(1, "failed on inotify_init()");
 
 	init = 1;
-	ftw(argv[1], add_dir, MAX_OPENFD);
+	ftw(argv[i], add_dir, MAX_OPENFD);
 	init = 0;
 
 	for (;;) {
 			warn("failed to read from inotify event queue");
 		for (cur = (struct inotify_event *)buf; (char *)cur - buf < len; cur += sizeof(struct inotify_event) + cur->len) {
 			if (cur->mask & (IN_CREATE | IN_ISDIR))
-				ftw(argv[1], add_dir, MAX_OPENFD);
+				ftw(argv[i], add_dir, MAX_OPENFD);
 			if (cur->mask & (IN_CREATE | IN_MODIFY) && !strcmp(cur->name, "out"))
 				win(cur->wd);
 		}