diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/configuration.md | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/docs/configuration.md b/docs/configuration.md index b286463..e30e55f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -337,6 +337,76 @@ configuration nothing they lack: they can write the command where it is used as Under `meta` is what a configuration says about itself; `importer` is all of it. +### Absent values + +An importer may say what tells that its value is absent, which is not the same as +failing: the key was taken out of the secret store, where a failure is a wrong +passphrase or a tool that isn't installed. Nothing says so unless the importer does, +in its table, with the one of these that is its kind's: + +```toml +[meta.importer] +secrets = { command = ["secrets", "show", "$(var:name)"], absent.status = 3 } +kept = { file = "/run/secrets/$(var:name)", absent.missing = true } +home = { env = "$(var:name)", absent.unset = true } +``` + +* `absent.status = N`, of a command: it exited with the status `N`. Tools disagree + about theirs (`grep` and `git config --get` exit with 1, `getent` with 2), and some + use one status for every failure, which then tells nothing: none is built in. Only + an exit counts: a command killed by a signal has no status, and fails. What it wrote + isn't looked at. +* `absent.missing = true`, of a file: there is no such file, nor a directory on the + way to it, or it is a link to nothing. One that can't be read, or is a directory, + fails. +* `absent.unset = true`, of an environment variable: it isn't set. One set to nothing + is there, and empty. + +Any status says it but 0, which says that there is a value: none is refused, and it is +the writer's to pick one that nothing else gives, as a failure with that status reads +as absent. What gives which: + +A program run as it is (a list of arguments, `["getent", "hosts", …]`) has every +status to itself: nothing is between it and its status. + +A shell is between a script and its status, in a shell command (`command = "…"`, +`cmd:…`, which `sh` runs, whichever shell that is on the system) as in a list that +names one (`["bash", "-c", …]`). What goes there: + +* The script says its status with `exit N`, and the shell exits with exactly that. + Without one, the status is the last command's, whichever that was. +* The shell exits by itself where it can't go on: a line it can't read, an expansion + that fails (`${name:?}`, a variable that isn't set under `set -u`), a redirection or + an assignment of a special built-in (`exec`, `.`, `export`, …) that fails. POSIX + leaves that status open, within 1 to 125. bash, dash and BusyBox ash use 1 and 2 + (bash 5.3, dash 0.5.13, ash 1.37, tried); other shells may use others. +* By POSIX, a shell gives 126 for a command that can't be run, 127 for one that isn't + found, and a status above 128 for one that a signal killed (128 and the signal's + number, with most shells). A script whose last command went so exits with that. +* So a script says absent with a status from 3 to 125, and where its tool says it by + another, turns that into one of its own. + +```toml +[meta.importer] +pass = { command = 'pass show $(var:name) || { test $? = 1 && exit 3; }', absent.status = 3 } +``` + +(That tool uses 1 for every failure, so this tells no more than it does: an example of +the spelling, not of a good signal.) + +An importer written as an argument takes (`cmd:…`, `file:…`, `env:…`) has no place to +say it: name the importer, and say it there. A named importer says it where it is +named, not where it is used. + +Only the importer asked for a value is absent. One inside another (a placeholder in a +command, in text, in what a named importer is used with) that is absent makes that one +fail: a command made of a value that isn't there is no command. + +continuum takes an option's absent value for a failure, and says that it is absent, +and what told. A program built on the `config` crate may do otherwise: `fetch` and its +kin give the typed error `import::Absent`, and `Importer::found_in` tells it apart from +a value. + ## Checking the configuration `--print-config` prints the effective configuration as JSON and exits: every option |
