Closed okibcn closed 1 year ago
system()
!= LuCI's call()
. Also {% %}
is a statement block. You need an expression block ({{ }}
) if you want to treat the expression result as output.
A working example could be:
{% import { popen } from "fs" -%}
The location of vi is {{ popen("which vi").read("all") }}
And the location of sh is {{ popen("which sh").read("all") }}
root@er-x:~# cat /tmp/test.ut
{% import { popen } from "fs" -%}
The location of vi is {{ popen("which vi").read("all") }}
And the location of sh is {{ popen("which sh").read("all") }}
root@er-x:~# ucode -T /tmp/test.ut
The location of vi is /bin/vi
And the location of sh is /bin/sh
root@er-x:~#
The stdout of system calls be inline with the template, instead of at the beginning.
For instance, lets create a file called
test.ut
with the following content:This is the expected output
Instead, it outputs this:
To be similar to Lua, it should deliver the stdout of a call not before everything else but in the right place.