summary refs log tree commit diff
path: root/bin/hi.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-15 02:23:06 -0500
committerJune McEnroe <june@causal.agency>2019-12-15 02:23:06 -0500
commit1499211ea2d0d6bfcdb386ddcf0831bdbaee9154 (patch)
tree3c080dd16bec505b7ed2968bb011741bbf00bcfb /bin/hi.c
parentMatch .profile and .shrc as shell in hi (diff)
downloadsrc-1499211ea2d0d6bfcdb386ddcf0831bdbaee9154.tar.gz
src-1499211ea2d0d6bfcdb386ddcf0831bdbaee9154.zip
Add option to default to text in hi
Diffstat (limited to 'bin/hi.c')
-rw-r--r--bin/hi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/hi.c b/bin/hi.c
index ec1a85ee..c8533e55 100644
--- a/bin/hi.c
+++ b/bin/hi.c
@@ -668,13 +668,14 @@ static bool findFormat(struct Format *format, const char *name) {
 int main(int argc, char *argv[]) {
 	setlocale(LC_CTYPE, "");
 
+	bool text = false;
 	const char *name = NULL;
 	struct Language lang = {0};
 	struct Format format = Formats[0];
 	const char *opts[OptionLen] = {0};
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "cf:l:n:o:"))) {
+	while (0 < (opt = getopt(argc, argv, "cf:l:n:o:t"))) {
 		switch (opt) {
 			break; case 'c': check(); return EX_OK;
 			break; case 'f': {
@@ -699,6 +700,7 @@ int main(int argc, char *argv[]) {
 					opts[key] = (val ? val : "");
 				}
 			}
+			break; case 't': text = true;
 			break; default: return EX_USAGE;
 		}
 	}
@@ -715,7 +717,7 @@ int main(int argc, char *argv[]) {
 		name = strrchr(path, '/');
 		name = (name ? &name[1] : path);
 	}
-	if (!lang.name && !matchLanguage(&lang, name)) {
+	if (!lang.name && !matchLanguage(&lang, name) && !text) {
 		errx(EX_USAGE, "cannot infer language for %s", name);
 	}
 	if (!opts[Title]) opts[Title] = name;