about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2017-03-10 08:56:52 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2017-03-12 19:37:18 +0000
commitd044530afd34c9d281953e304e9b2a622cb0c0f0 (patch)
tree1de98d96e15813cdf8728707ff459386998d557a
parent2ff71e84ba6e2b92261b7052721e15ce35c496ca (diff)
downloadzsh-d044530afd34c9d281953e304e9b2a622cb0c0f0.tar.gz
zsh-d044530afd34c9d281953e304e9b2a622cb0c0f0.tar.xz
zsh-d044530afd34c9d281953e304e9b2a622cb0c0f0.zip
40816: Document interaction of 'print -P' and 'print -f'.
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/builtins.yo3
-rw-r--r--Test/D01prompt.ztst10
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5bcd69961..fe0446ed4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-12  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
+	* 40816: Doc/Zsh/builtins.yo, Test/D01prompt.ztst: Document
+	interaction of 'print -P' and 'print -f'.
+
 2017-03-12  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
 
 	* 40820: Test/V09datetime.ztst: add a few tests of strftime,
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 37e386581..81c201f70 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1252,6 +1252,9 @@ Perform prompt expansion (see
 ifzman(EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
 ifnzman(noderef(Prompt Expansion))\
 ).
+In combination with `tt(-f)',
+prompt escape sequences are parsed only within interpolated arguments,
+not within the format string.
 )
 item(tt(-r))(
 Ignore the escape conventions of tt(echo).
diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 607ffb698..08187287d 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -82,9 +82,12 @@
 # We could test for that, but we can't be bothered.
 # I hope LC_ALL is enough to make the format what's expected.
 
+# The $date2 assignment tests that %s is interpreted as a printf format
+# string, rather than as a prompt escape (end standout).
+
   LC_ALL=C
   date1=$(print -P %w)
-  date2=$(print -P %W)
+  date2=$(print -P -f %s %W)
   date3=$(print -P %D)
   if [[ $date1 != [A-Z][a-z][a-z][[:blank:]]##[0-9]## ]]; then
     print "Date \`$date1' is not in the form \`Day DD' (e.g. \`Mon 1'"
@@ -201,3 +204,8 @@
 ?+zsh_directory_name:14> return 0
 ?+fn:7> local d='~[<parent>:l]'
 ?+fn:8> print '~[<parent>:l]'
+
+# Test that format strings are not subject to prompt expansion
+ print -P -f '%%Sfoo%%s\n' bar
+0:print -P -f
+>%Sfoo%s