about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndreyDobrovolskyOdessa <andrey.dobrovolsky.odessa@gmail.com>2021-03-20 11:55:32 +0200
committerLeah Neukirchen <leah@vuxu.org>2021-03-26 19:09:49 +0100
commit7eede3b7a8139a9a9aad2b31047d26959f5ac4bb (patch)
treef02f892bf710863b80193fce0d5b7c3e8fcd418a
parentca8316c43c52bd9961530f218fc4736ed71c6764 (diff)
downloadredo-c-7eede3b7a8139a9a9aad2b31047d26959f5ac4bb.tar.gz
redo-c-7eede3b7a8139a9a9aad2b31047d26959f5ac4bb.tar.xz
redo-c-7eede3b7a8139a9a9aad2b31047d26959f5ac4bb.zip
Avoid duplicate flags initialization in main()
Closes: #18 [via git-merge-pr]
-rw-r--r--redo.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/redo.c b/redo.c
index 139142a..2a82dc9 100644
--- a/redo.c
+++ b/redo.c
@@ -923,11 +923,6 @@ main(int argc, char *argv[])
 	if (level < 0)
 		level = 0;
 
-	fflag = envfd("REDO_FORCE");
-	kflag = envfd("REDO_KEEP_GOING");
-	xflag = envfd("REDO_TRACE");
-	sflag = envfd("REDO_STDOUT");
-
 	if ((program = strrchr(argv[0], '/')))
 		program++;
 	else
@@ -936,19 +931,15 @@ main(int argc, char *argv[])
 	while ((opt = getopt(argc, argv, "+kxfsj:C:")) != -1) {
 		switch (opt) {
 		case 'k':
-			kflag = 1;
 			setenvfd("REDO_KEEP_GOING", 1);
 			break;
 		case 'x':
-			xflag = 1;
 			setenvfd("REDO_TRACE", 1);
 			break;
 		case 'f':
-			fflag = 1;
 			setenvfd("REDO_FORCE", 1);
 			break;
 		case 's':
-			sflag = 1;
 			setenvfd("REDO_STDOUT", 1);
 			break;
 		case 'j':
@@ -968,6 +959,11 @@ main(int argc, char *argv[])
 	argc -= optind;
 	argv += optind;
 
+	fflag = envfd("REDO_FORCE");
+	kflag = envfd("REDO_KEEP_GOING");
+	xflag = envfd("REDO_TRACE");
+	sflag = envfd("REDO_STDOUT");
+
 	dir_fd = keepdir();
 
 	if (strcmp(program, "redo") == 0) {