adds support for overriding what the ARGV looks like in a module invocation. In other words, you can override the CGI 1.1 format of ${SCRIPT_NAME} ${ARGS} to be something else
Why do we need this?
Scripting engines read files off of the filesystem and then interpret them. Examples:
Ruby
Python
Node
However, they all make some assumptions about the shape of the argv array. Specifically, they assume that the array is:
0: script engine
1: top-level script
2...: the args that should be passed to the script
So, for example, a ruby invocation might be ruby env.rb --some args.
In the CGI days, we basically worked around this expectation with shell scripts. But we can't do that in Wagi. So the proposed solution is to allow the argv to be rewritten according to a user-specified pattern.
Take an example URL like this: http://localhost:3000/?p1=v1&p2=v2.
The above argv translates that to: ruby /env.rb / p1=v1 p2=v2. And ruby.wasm (which is ruby compiled to Wasm) skips arg[0], reads the /env.rb into the engine, and then passes that script the argv ["/", "p1=v1", "p2=v2"].
This PR does the following:
argv
field to[module]
in modules.tomlargv
feature to Bindle modulesARGV
looks like in a module invocation. In other words, you can override the CGI 1.1 format of${SCRIPT_NAME} ${ARGS}
to be something elseWhy do we need this?
Scripting engines read files off of the filesystem and then interpret them. Examples:
However, they all make some assumptions about the shape of the argv array. Specifically, they assume that the array is:
So, for example, a
ruby
invocation might beruby env.rb --some args
.In the CGI days, we basically worked around this expectation with shell scripts. But we can't do that in Wagi. So the proposed solution is to allow the
argv
to be rewritten according to a user-specified pattern.Example:
Take an example URL like this:
http://localhost:3000/?p1=v1&p2=v2
.The above
argv
translates that to:ruby /env.rb / p1=v1 p2=v2
. Andruby.wasm
(which isruby
compiled to Wasm) skips arg[0], reads the/env.rb
into the engine, and then passes that script the argv["/", "p1=v1", "p2=v2"]
.Signed-off-by: Matt Butcher matt.butcher@fermyon.com