Skip to content

Commit 9bd75b4

Browse files
committed
Add support for shebang invocation - trim esh shebang from output
Resolves #17
1 parent 1df7862 commit 9bd75b4

File tree

7 files changed

+13
-0
lines changed

7 files changed

+13
-0
lines changed

esh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ function end_text() {
145145
state = "UNDEF"
146146
}
147147
function process_line() {
148+
if (linenos[depth] == 0 && match(buff, "^#! */usr/bin/env esh([ \t]|$)")) {
149+
return
150+
}
148151
print_nl = 1
149152
linenos[depth]++
150153

esh.1.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ Opening and closing tag may not be at the same line.
119119
Text outside a tag becomes literal text, but it is subject to any tagged shell code surrounding it.
120120
For example, text surrounded by a tagged *if* statement only appears in the output if the condition is true.
121121

122+
If the first line of the template starts with `#!/usr/bin/env esh`, this line will be removed from the output (since 0.4.0).
123+
122124

123125
== EXAMPLES
124126

tests/incl/esh-shebang.esh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /usr/bin/env esh
2+
This line is included from incl/esh-shebang.esh

tests/test-esh-shebang.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello from esh-shebang!

tests/test-esh-shebang.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env esh
2+
Hello from <%= ${TEST_NAME#test-} %>!

tests/test-include-esh-shebang.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This line is included from incl/esh-shebang.esh.

tests/test-include-esh-shebang.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env esh
2+
<%+ incl/esh-shebang.esh %>.

0 commit comments

Comments
 (0)