about summary refs log tree commit diff
path: root/fq.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-09 20:02:15 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-09 20:02:15 +0200
commit2487571008ee5c6d69ffaa85c40035d6d8b81912 (patch)
treefe1c7b8df3a9a59a442b3c6aee48ea5c39eb7fcf /fq.c
parent77995a181a04fb60398ca3aa8e6bff69cc8c4fad (diff)
downloadnq-2487571008ee5c6d69ffaa85c40035d6d8b81912.tar.gz
nq-2487571008ee5c6d69ffaa85c40035d6d8b81912.tar.xz
nq-2487571008ee5c6d69ffaa85c40035d6d8b81912.zip
fq: cleanups
Diffstat (limited to 'fq.c')
-rw-r--r--fq.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/fq.c b/fq.c
index 8dbb3f3..632404a 100644
--- a/fq.c
+++ b/fq.c
@@ -56,8 +56,6 @@ main(int argc, char *argv[])
 	ssize_t rd;
 	int didsth = 0, seen_nl = 0;
 	int opt = 0, aflag = 0, qflag = 0;
-	DIR *dir;
-	struct dirent *d;
 	char *path;
 
 #ifdef USE_INOTIFY
@@ -82,12 +80,16 @@ main(int argc, char *argv[])
 	path = getenv("NQDIR");
 	if (!path)
 		path = ".";
+
 	dirfd = open(path, O_RDONLY);
 	if (dirfd < 0)
 		exit(111);
 
-	if (optind == argc) {
+	if (optind == argc) {	/* behave as if $NQDIR/,* was passed. */
+		DIR *dir;
+		struct dirent *d;
 		int len = 0;
+
 		argc = 0;
 		argv = 0;
 		optind = 0;
@@ -105,7 +107,8 @@ main(int argc, char *argv[])
 				if (!argv)
 					exit(222);
 			}
-			if (!(argv[argc] = strdup(d->d_name)))
+			argv[argc] = strdup(d->d_name);
+			if (!argv[argc])
 				exit(222);
 			argc++;
 		}
@@ -127,8 +130,8 @@ main(int argc, char *argv[])
 		if (fd < 0)
 			continue;
 
-		/* skip not running jobs, unless we did not output anything yet
-		 * and are at the last argument.  */
+		/* skip not running jobs, unless -a was passed, or we did not
+		 * output anything yet and are at the last argument.  */
 		if (!aflag && !islocked(fd) && (didsth || i != argc - 1))
 			continue;