about summary refs log tree commit diff
path: root/xe.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-11-03 23:12:59 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-11-03 23:12:59 +0100
commitb4a3e45856da6f4755943c190c712ce7fcf92dc0 (patch)
treed93760fa0f63ff7321291f2039b0e7a9f9949d24 /xe.c
parentc77fd48024d6de425e890f74cc11142085e4b5b8 (diff)
downloadxe-b4a3e45856da6f4755943c190c712ce7fcf92dc0.tar.gz
xe-b4a3e45856da6f4755943c190c712ce7fcf92dc0.tar.xz
xe-b4a3e45856da6f4755943c190c712ce7fcf92dc0.zip
run: bail out early when there is no command to run
Diffstat (limited to 'xe.c')
-rw-r--r--xe.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/xe.c b/xe.c
index 018ee3b..30231eb 100644
--- a/xe.c
+++ b/xe.c
@@ -215,6 +215,11 @@ run()
 
 	scanargs();
 
+	if (!args[0]) {
+		fprintf(stderr, "xe: no command\n");
+		exit(126);
+	}
+
 	if (nflag) {
 		trace();
 		runjobs--;
@@ -252,10 +257,6 @@ run()
 			close(pipefd[1]);
 		}
 
-		if (!args[0]) {
-			fprintf(stderr, "xe: no command\n");
-			exit(126);
-		}
 		if (qflag) {
 			int fd = open("/dev/null", O_RDONLY);
 			if (fd >= 0) {
@@ -264,7 +265,9 @@ run()
 				close(fd);
 			}
 		}
+
 		execvp(args[0], args);
+
 		int status = (errno == ENOENT ? 127 : 126);
 		fprintf(stderr, "xe: %s: %s\n", args[0], strerror(errno));
 		exit(status);