about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-06-20 16:25:18 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-06-20 16:25:18 +0200
commitcdd07058705eaef11fcfe4a8fe75e32da6aa5b24 (patch)
tree9ef21ed012d8a0962bcecd6f64e077d8620299b6
parent2645de45e4aec89a468de5387cf8cfb604acf547 (diff)
downloadlr-cdd07058705eaef11fcfe4a8fe75e32da6aa5b24.tar.gz
lr-cdd07058705eaef11fcfe4a8fe75e32da6aa5b24.tar.xz
lr-cdd07058705eaef11fcfe4a8fe75e32da6aa5b24.zip
lr: support @file to read file names from file
-rw-r--r--lr.110
-rw-r--r--lr.c9
2 files changed, 18 insertions, 1 deletions
diff --git a/lr.1 b/lr.1
index 11d106c..b1e31da 100644
--- a/lr.1
+++ b/lr.1
@@ -1,4 +1,4 @@
-.Dd January 4, 2016
+.Dd June 20, 2017
 .Dt LR 1
 .Os
 .Sh NAME
@@ -28,6 +28,14 @@ makes
 read file names from standard input,
 instead of traversing
 .Ar path .
+Likewise, the special
+.Ar path
+argument
+.Ic \&@ Ns Ar file
+makes
+.Nm
+read file names from
+.Ar file .
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
diff --git a/lr.c b/lr.c
index 29463a4..bf7590d 100644
--- a/lr.c
+++ b/lr.c
@@ -1868,6 +1868,15 @@ traverse(const char *path)
 	if (path[0] == '-' && !path[1])
 		return traverse_file(stdin);
 
+	if (path[0] == '@') {
+		FILE *f = fopen(path + 1, "r");
+		if (!f)
+			parse_error("can't open input file '%s'", path + 1);
+		int r = traverse_file(f);
+		fclose(f);
+		return r;
+	}
+
 	prefixl = strlen(path);
 	while (path[prefixl-1] == '/')
 		prefixl--;