summary refs log tree commit diff
path: root/bin
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
commit848a881536ad3721b1b31416b6af8b6bc8c0afa9 (patch)
tree185a504fb2fc56541e0e53d714ee27e9e5bf05c2 /bin
parentMatch .profile and .shrc as shell in hi (diff)
downloadsrc-848a881536ad3721b1b31416b6af8b6bc8c0afa9.tar.gz
src-848a881536ad3721b1b31416b6af8b6bc8c0afa9.zip
Add option to default to text in hi
Diffstat (limited to '')
-rw-r--r--bin/hi.c6
-rw-r--r--bin/man1/hi.17
2 files changed, 10 insertions, 3 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 89ae325d..4cbca999 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;
diff --git a/bin/man1/hi.1 b/bin/man1/hi.1
index d8a4b4ee..517fbab9 100644
--- a/bin/man1/hi.1
+++ b/bin/man1/hi.1
@@ -1,4 +1,4 @@
-.Dd December 11, 2019
+.Dd December 15, 2019
 .Dt HI 1
 .Os
 .
@@ -8,6 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
+.Op Fl t
 .Op Fl f Ar format
 .Op Fl l Ar lang
 .Op Fl n Ar name
@@ -40,6 +41,10 @@ to infer the input language.
 Set output format options.
 .Ar opts
 is a comma-separated list of options.
+.It Fl t
+Default to
+.Cm text
+if the input language cannot be inferred.
 .El
 .
 .Ss Output Formats