From 34434f7fd5a6bab1884a63c96679f48045f4bffd Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 30 Nov 2026 21:06:06 +0000 Subject: config: placeholders in parentheses, for where braces are another language's A placeholder may be written $(env:NAME), $(file:PATH) or $(cmd:COMMAND), ending at the parenthesis matching its own: the same as with braces, nesting and all. A configuration written in Nix, or passed through a systemd unit, needs no escapes so. --- docs/configuration.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/configuration.md b/docs/configuration.md index 27b73be..e40d00e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -197,6 +197,19 @@ in shell quotes (`'...'`, `"..."`) or after a backslash don't count, so a comman hold `$`, quotes and braces of its own. `literal:` on the command line turns this off too. +A placeholder may be written with parentheses instead, `$(env:NAME)`, `$(file:PATH)`, +`$(cmd:COMMAND)`: the same, ending at the `)` that matches its `(`, parentheses +balancing and counting as braces do. So a configuration written in a language with a +`${…}` of its own, as Nix has, or passed through one (a systemd unit's `ExecStart=`), +needs no escapes there: + +```nix +{ alias = "$(env:SITE)-$(cmd:hostname -s)"; } +``` + +A command whose own parentheses don't balance outside quotes (a `case` pattern) is +written with braces. + ```sh continuum --alias 'node-${env:HOSTNAME}' ``` @@ -216,9 +229,10 @@ 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 +There, only `${env:`, `${file:` and `${cmd:` begin a placeholder, or the same with +`$(`, and every other `$` stays as it is, a command's being its shell's (`$HOME`, +`$(…)`, `${x:-y}`); `$${` and `$$(` give the shell a `${` or 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; -- cgit v1.3.1