From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 12419 invoked from network); 28 Jul 2023 09:48:28 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 28 Jul 2023 09:48:28 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1690537708; b=gdqSDxhpGZeyU1Qx9BwjIeq9zykAYInFR+OT/F7xUkQDLJT/J5Fau85G2ae+mtFnpljfqRdLz/ lk+8eMM7J7jV1ZDh7drCkdH4moux3PSmFFt09AmobmTj+KJMTyB8BJW+UG9roxT30GNhz0i6m0 ABlnhQm+gd7A8MvyhWNxDAQm1kfTs6YZr/NmdCw0h3HrHbvAtB5CuN6WLLl7+No+GpEAxYBYUv tKONmdFxi0mOR/3klrH9ghcciu4ajctdqeMP+/Xci2bwvhjzUPwkYGdt2sH9Ab0tnPBvkCu37c coN/olIm9BOBFLPdzx2VaY61cCpW/wAAQ45833AV1bylHQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1690537708; bh=EG2l5286aobr6vVEuqgMaVlyPyFIg9proRWdJ6ZviKk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date: DKIM-Signature; b=dEe5qsb63QN2I6ATyKJYwdOYIvXSFlITlOVQaGFvvJUq4JDPGavOZU/BBVxYTSvvfz/B+RQr9v p0acQwyAGNvxOkKDo1eLnIQxWh4RpgQtJjvhCTEFReaDyZSGdtWs8SFH8k+EoD/jzbn41SzUkz zujh4rAjoMDxkg6JVN5May7Gjj+nGjdqKg10l7ndT013fCZ90SMbGqj1oRVqvGmvxbzhJbwbFh 1F/lO5f2FcnNIF/Sb5Noy5/aepEy/tjZ8cS8M0RkFLv+8NrsKIroATvnH+lOjXm9ItRoxfmmlB oamPW9IdJLJMXaoMGmQ/QrNy+CaxPbLOh8dV1pohB0Gs3g==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=d1Vyu8UZnvE4IIWirBNRwCC1jDcp/PjFinGzN7mAJVA=; b=iVIJG35Nt5mFm02Z9rhi67uHKH 7y2OWnFHCp9TnNywL3bMVvus9e5gJ/SoOBcVgkLPsQYvxSE9n6ZCmRmJVYoA9NJh30q4j0i+7I6LA 5FFqzTFCQkE4/9HEX6WjaFfTAdyD86ebNMco+kANmv0etIbxL3LQY7Fnt0tLVg8/H8dYBg6s56Q/k ENUcMNpR064IIy1RSBp41gu8LMnfNCq893PCpPmr5QCv3HFFl8LhD0uWBGjfkUQlsFQIU4P5vQxOZ AnByoXAyRsF1ovjdAiRy4yR/rM81+OgVVzGUcNmI2ItYePuGf/snOTg8uK5Jbm/JgWK+E6SvajyTl Wkxyx7/A==; Received: by zero.zsh.org with local id 1qPK5D-000DOT-LR; Fri, 28 Jul 2023 09:48:27 +0000 Authentication-Results: zsh.org; iprev=pass (relay3-d.mail.gandi.net) smtp.remote-ip=217.70.183.195; dmarc=none header.from=chazelas.org; arc=none Received: from relay3-d.mail.gandi.net ([217.70.183.195]:44377) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1qPK4d-000D5S-9Q; Fri, 28 Jul 2023 09:47:53 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 473E560013 for ; Fri, 28 Jul 2023 09:47:49 +0000 (UTC) Date: Fri, 28 Jul 2023 10:47:48 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: [PATCH][doc] clarify order of backslash and prompt expansion in print -P Message-ID: <20230728094748.vmnnatnyxo7rs2v7@chazelas.org> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-GND-Sasl: stephane@chazelas.org X-Seq: 51997 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Also remind that you don't need to escape the backslashes if using print -rP as I've seem people going through all the trouble of doing that escaping when they could just have use -r. diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index 909012c8e..5b31bcd6c 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -3,8 +3,11 @@ chapter(Prompt Expansion) sect(Expansion of Prompt Sequences) cindex(prompt expansion) cindex(expansion, prompt) -Prompt sequences undergo a special form of expansion. This type of expansion -is also available using the tt(-P) option to the tt(print) builtin. +Prompt sequences undergo a special form of expansion. This type of +expansion is also available using the tt(-P) option to the tt(print) +builtin, performed there em(after) backslash expansion unless used in +combination with the tt(-r) option to disable the latter or tt(-f) to +specify a format string. pindex(PROMPT_SUBST, use of) If the tt(PROMPT_SUBST) option is set, the prompt string is first subjected to @@ -358,10 +361,12 @@ For example, if the current directory is `tt(/home/pike)', the prompt `tt(%8<..<%/)' will expand to `tt(..e/pike)'. In this string, the terminating character (`tt(<)', `tt(>)' or `tt(])'), or in fact any character, may be quoted by a preceding `tt(\)'; note -when using tt(print -P), however, that this must be doubled as the -string is also subject to standard tt(print) processing, in addition -to any backslashes removed by a double quoted string: the worst case -is therefore `tt(print -P "%<\\\\<<...")'. +when using tt(print -P) without tt(-r)/tt(-f), however, that this must +be doubled as the string is also subject to standard tt(print) +processing, in addition to any backslashes removed by a double quoted +string: the worst case is therefore `tt(print -P "%<\\\\<<...")' to +escape the `tt(<)' and achieve the same as `tt(print -rP '%2<\<<...')' +or `tt(print -Pf '%s\n' '%2<\<<...')'. If the var(string) is longer than the specified truncation length, it will appear in full, completely replacing the truncated string.