aboutsummaryrefslogtreecommitdiffstats
path: root/docs/configuration.md
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-29 00:29:50 +0000
committertv <tv@krebsco.de>2026-11-29 00:29:50 +0000
commitd56436c3e5ee7b5659e1c2171c5c7af2d3c4eccb (patch)
treec4da35c7acdf8b250ada8ec9adec65274e1c4016 /docs/configuration.md
parent479246f98be360b5943458bd58d07e6d46f81fd0 (diff)
config: placeholders nest, what one gives going in as data
A name, a path, a command and each argument of an importer may hold placeholders of their own. There only ${env:, ${file: and ${cmd: begin one, $${ is a ${, and every other $ stays: a command's are its shell's. What a placeholder gives is never run. Into a name, a path and an argument it goes as text, an argument staying one. A shell command gets it as a positional parameter, the placeholder becoming a reference to it, "${1}", or ${1} inside double quotes: no part of the script, whatever it holds. import::Shell tells where in a script a place is, as far as that reference needs; where it can't be written as one word (single quotes, backquotes, $((…)), the shell's ${…}, after a backslash or a here-document), the command is refused. What it gets wrong can refuse a reference or have the shell split it, never run it. An importer has its directory itself (Importer::dir), a file's path joined with it when read, so that a path may hold placeholders.
Diffstat (limited to 'docs/configuration.md')
-rw-r--r--docs/configuration.md25
1 files changed, 24 insertions, 1 deletions
diff --git a/docs/configuration.md b/docs/configuration.md
index 0efdfc3..00f2386 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -192,7 +192,7 @@ Any other text value can mix fixed text with imported values: each `${env:NAME}`
an error (a shell-style `$NAME` would otherwise silently stay as it is). A placeholder
ends at the `}` that matches its `{`: braces inside it balance, and in a command, braces
in shell quotes (`'...'`, `"..."`) or after a backslash don't count, so a command may
-hold `$`, quotes and braces of its own. Placeholders don't nest. `literal:` on the
+hold `$`, quotes and braces of its own. `literal:` on the
command line turns this off too.
```sh
@@ -205,6 +205,29 @@ alias = "${env:SITE}-${cmd:hostname -s}"
libp2p-listen = ['''/ip6/${cmd:ip -j addr show wireguard | jq -r '.[].addr_info[]|select(.family=="inet6" and .scope=="global").local'}/tcp/9661''']
```
+Placeholders nest: a name, a path, a command, and each argument of a command given as a
+list, may hold placeholders of their own, in a file's importers and on the command line
+alike:
+
+```toml
+tor-key = "${cmd:secrets ${env:HOSTNAME} show tor}"
+alias = { command = ["hostname-of", "${env:SITE}"] }
+```
+
+There, only `${env:`, `${file:` and `${cmd:` begin a placeholder, and every other `$`
+stays as it is, a command's being its shell's (`$HOME`, `$(…)`, `${x:-y}`); `$${` gives
+the shell a `${` that would begin one. What a placeholder gives goes in as it is, never
+as something to run:
+
+* into a name, a path and an argument as text, an argument staying one argument;
+* into a shell command as one word, whatever it holds (spaces, quotes, `;`, `$(…)`): it
+ is handed to the shell as a positional parameter, and the placeholder becomes a
+ reference to that (`"${1}"`), so the shell reads none of it as part of the command. A
+ placeholder where no such reference can be written is an error that says so: inside
+ single quotes, backquotes, `$((…))`, a `${…}` of the shell's, after a backslash, and
+ after a here-document. A command that evaluates what it is given (`eval`, `sh -c`)
+ still does.
+
A command that prints several lines (above: several addresses) doesn't give one item
per line: as a list element the text is one item, line breaks and all, and as a whole
list value it is split at commas and line breaks, the fixed text going with the first