Skip to content

Commit db8f4e3

Browse files
authored
Merge pull request #176 from Univers42/docs/issue-134-print-p-preview
docs: clarify print -P prompt preview caveat (#134)
2 parents 1c6862f + 58a29df commit db8f4e3

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎USER_DOC.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ What is live at every render, and what is not:
114114
| `$((…))` | yes |
115115
| `$(…)` and backquotes | **no** — the text stays on screen as written; it would fork on every redraw |
116116

117+
**Preview caveat:** `print -P` formats its expanded input again using zsh's
118+
prompt escapes. If a variable contains `%` sequences, `print -rP "[${V}]"`
119+
can interpret them as prompt escapes even though the live prompt leaves the
120+
expanded value literal. Do not treat `print -P` output as an exact preview of
121+
variable-backed prompt segments; this mismatch is tracked in [issue #134](https://github.com/Univers42/hellish/issues/134).
122+
117123
For a computed segment, set a variable from a hook and put the variable in
118124
the prompt. `HELLISH_PRECMD_FUNCS` runs once before each prompt
119125
(`hellishrc.example`, section 5b):

‎wiki/interactive.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ loaded, and a shell run from a checkout loads it with
106106

107107
**PS1 is bilingual.** Both escape languages render in a plain PS1 — paste `%n@%m %~ %#` or
108108
`\u@\h \w \$` and either works, while `100% `, csh-style `%> ` and the strftime percents inside
109-
`$(date +%H:%M)` or `\D{%M}` survive literally. `PROMPT` and `print -P` keep exact zsh semantics
110-
(measured against zsh 5.9), and under `set -o zsh`, PS1 *is* PROMPT, as in zsh.
109+
`$(date +%H:%M)` or `\D{%M}` survive literally. `PROMPT` keeps exact zsh semantics (measured against zsh 5.9), and under
110+
`set -o zsh`, PS1 *is* PROMPT, as in zsh. `print -P` uses zsh's prompt
111+
formatter too, but it can re-interpret percent escapes in expanded variable
112+
contents; its output is not always an exact preview of the live prompt (issue
113+
[#134](https://github.com/Univers42/hellish/issues/134)).
111114

112115
**What is live, and what is not.** `$VAR`, `${VAR…}`, `$?` and `$((…))` are expanded every time
113116
the prompt is drawn. Command substitution is not: `$(…)` and backquotes stay on screen as the

0 commit comments

Comments
 (0)