From 79cbd2ab1bd016c12e3fd70df4192ebe7c6ed60e Mon Sep 17 00:00:00 2001 From: Robert <766670+rben01@users.noreply.github.com> Date: Mon, 8 Sep 2025 18:58:25 -0400 Subject: [PATCH] Improve explanation of how the shell handles quotes in config.md (#3169) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Clarify how the shell's handling of quotes affects the interpretation of TOML values in `--config`/`-c` * Provide examples of the right way to pass complex TOML values * The previous explanation incorrectly demonstrated how to pass TOML values to `--config`/`-c` (misunderstanding how the shell’s handling of quotes affects things) and would result in invalid invocations of `codex`. --- docs/config.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/config.md b/docs/config.md index a7f52249..aebdf9ce 100644 --- a/docs/config.md +++ b/docs/config.md @@ -6,9 +6,12 @@ Codex supports several mechanisms for setting config values: - Config-specific command-line flags, such as `--model o3` (highest precedence). - A generic `-c`/`--config` flag that takes a `key=value` pair, such as `--config model="o3"`. - The key can contain dots to set a value deeper than the root, e.g. `--config model_providers.openai.wire_api="chat"`. - - Values can contain objects, such as `--config shell_environment_policy.include_only=["PATH", "HOME", "USER"]`. - - For consistency with `config.toml`, values are in TOML format rather than JSON format, so use `{a = 1, b = 2}` rather than `{"a": 1, "b": 2}`. - - If `value` cannot be parsed as a valid TOML value, it is treated as a string value. This means that both `-c model="o3"` and `-c model=o3` are equivalent. + - For consistency with `config.toml`, values are a string in TOML format rather than JSON format, so use `key='{a = 1, b = 2}'` rather than `key='{"a": 1, "b": 2}'`. + - The quotes around the value are necessary, as without them your shell would split the config argument on spaces, resulting in `codex` receiving `-c key={a` with (invalid) additional arguments `=`, `1,`, `b`, `=`, `2}`. + - Values can contain any TOML object, such as `--config shell_environment_policy.include_only='["PATH", "HOME", "USER"]'`. + - If `value` cannot be parsed as a valid TOML value, it is treated as a string value. This means that `-c model='"o3"'` and `-c model=o3` are equivalent. + - In the first case, the value is the TOML string `"o3"`, while in the second the value is `o3`, which is not valid TOML and therefore treated as the TOML string `"o3"`. + - Because quotes are interpreted by one's shell, `-c key="true"` will be correctly interpreted in TOML as `key = true` (a boolean) and not `key = "true"` (a string). If for some reason you needed the string `"true"`, you would need to use `-c key='"true"'` (note the two sets of quotes). - The `$CODEX_HOME/config.toml` configuration file where the `CODEX_HOME` environment value defaults to `~/.codex`. (Note `CODEX_HOME` will also be where logs and other Codex-related information are stored.) Both the `--config` flag and the `config.toml` file support the following options: