Anonymous avatar 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);
 		}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.