Commits

Anonymous committed 481dd85

changing cwd to pcw

Comments (0)

Files changed (2)

+#include <unistd.h>
+#include <err.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <errno.h>
 	FILE *in, *out;
 	char buf[4096];
 	fd_set rd;
-	struct inotify_event *cur;
 
 	for (i = 1; i < argc; i++) {
 		if (argv[i][0] != '-')
 
 	out = mopen(argv[i + 1], "w");
 
-	if (!quiet) printf("-------------------- new text starts here --------------------\n");
+	if (!quiet) fprintf(stderr, "-------------------- new text starts here --------------------\n");
 
 	if ((evq = inotify_init()) < 0)
 		err(1, "failed inotify_init()");
+#include <err.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
 #define MAX_WATCH   512
 
 int evq, init;
-char paths[MAX_WATCH][PATH_MAX] = {0};
+char paths[MAX_WATCH][PATH_MAX] = {{0}};
 int wins[MAX_WATCH] = {0};
 
 char term[16] = "urxvt";
 
 void usage(void)
 {
-	printf("Usage: cwd [-t terminal] [-v] dir\n");
+	printf("Usage: pcw [-t terminal] [-v] dir\n");
 	exit(1);
 }
 
 void win(int wd)
 {
-	char path[PATH_MAX], out[PATH_MAX], in[PATH_MAX];
+	char out[PATH_MAX], in[PATH_MAX];
 	char *wincmd[] = {term, "-title", paths[wd], "-e", "srw", "cw", "-f", out, in, NULL};
 
 	if (wins[wd])
 	struct stat st;
 
 	if (!(typeflag & FTW_D))
-		return;
+		return 0;
 
 	if ((wd = inotify_add_watch(evq, fpath, IN_CREATE | IN_MODIFY)) < 0)
 		warn("failed on inotify_add_watch on %s", fpath);
 			usage();
 		switch (argv[i][1]) {
 			case 't' : if (i + 1 >= argc) usage(); strncpy(term, argv[i + 1], sizeof(term)); break;
-			case 'v' : printf("cwd-"VERSION" © Evan Gates\n"); exit(1);
+			case 'v' : printf("pcw-"VERSION" © Evan Gates\n"); exit(1);
 			default  : usage();
 		}
 	}
 		errx(1, "%s does not exist or is not a directory", argv[1]);
 
 	if (signal(SIGCHLD, sigchld) == SIG_ERR)
-		err("failed installing SIGCHLD handler");
+		err(1, "failed installing SIGCHLD handler");
 
 	if ((evq = inotify_init()) < 0)
 		err(1, "failed on inotify_init()");