summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-26 21:11:36 -0500
committerJune McEnroe <june@causal.agency>2021-01-26 21:11:36 -0500
commitdba506c3818481d3b1352ade6055abfdd918e1ec (patch)
treed820ab50c94bfeb5ae8a15f95f7acb675b37c888
parentInstall vi on Linux and nvi on macOS (diff)
downloadsrc-dba506c3818481d3b1352ade6055abfdd918e1ec.tar.gz
src-dba506c3818481d3b1352ade6055abfdd918e1ec.zip
Use First state to match keyword at beginning of line
Otherwise keywords at the beginnings of lines with preceeding
whitespace are not matched.
-rw-r--r--bin/sh.l5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/sh.l b/bin/sh.l
index 77dd2518..fcd5ce35 100644
--- a/bin/sh.l
+++ b/bin/sh.l
@@ -81,6 +81,10 @@ reserved [!{}]|else|do|elif|for|done|fi|then|until|while|if|case|esac
 	return Subst;
 }
 
+"\n" {
+	BEGIN(push(First));
+	return Normal;
+}
 [&();|]|"&&"|";;"|"||" {
 	BEGIN(push(First));
 	return Operator;
@@ -89,7 +93,6 @@ reserved [!{}]|else|do|elif|for|done|fi|then|until|while|if|case|esac
 	return Operator;
 }
 
-^{reserved} { return Keyword; }
 <First>{
 	[[:blank:]]+ { return Normal; }
 	{reserved} {