Skip to content

Commit 64b170c

Browse files
committed
runtime: Document args[0] and the no-usable-args fallback
Leaning on Go's docs [1]: > Args holds command line arguments, including the command as > Args[0]. If the Args field is empty or nil, Run uses {Path}. for the fallback wording. This restores the ability to explicitly set args[0] independent of the path, which was requested in #34 [2] and ack-ed by Micheal [3] and Mrunal [4], but didn't match the examples that landed with #34. [1]: http://golang.org/pkg/os/exec/#Cmd [2]: #34 (comment) [3]: #34 (comment) [4]: #34 (comment) Signed-off-by: W. Trevor King <[email protected]>
1 parent 94c1803 commit 64b170c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

runtime.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
4040
"prestart": [
4141
{
4242
"path": "/usr/bin/fix-mounts",
43-
"args": ["arg1", "arg2"],
43+
"args": ["fix-mounts", "arg1", "arg2"],
4444
"env": [ "key1=value1"]
4545
},
4646
{
@@ -50,10 +50,14 @@ If a hook returns a non-zero exit code, then an error is logged and the remainin
5050
"poststop": [
5151
{
5252
"path": "/usr/sbin/cleanup.sh",
53-
"args": ["-f"]
53+
"args": ["cleanup.sh", "-f"]
5454
}
5555
]
5656
}
5757
```
5858

59-
`path` is required for a hook. `args` and `env` are optional.
59+
`path` is required for a hook.
60+
`args` and `env` are optional.
61+
`args` includes the command as `args[0]`.
62+
If the `args` field is missing, empty, or `null`, the runtime will use `[path]`.
63+
In the example above, that means that `/usr/bin/setup-network` will be executed with `/usr/bin/setup-network` as `args[0]` and no other arguments.

0 commit comments

Comments
 (0)