zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: [PATCH] Document interaction of 'print -P' and 'print -f'.
Date: Fri, 10 Mar 2017 08:56:52 +0000	[thread overview]
Message-ID: <1489136212-32247-1-git-send-email-danielsh@fujitsu.shahaf.local2> (raw)

---
 Doc/Zsh/builtins.yo |  3 +++
 Test/D01prompt.ztst | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 37e3865..81c201f 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 607ffb6..0818728 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


                 reply	other threads:[~2017-03-10  9:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1489136212-32247-1-git-send-email-danielsh@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).