From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26039 invoked by alias); 12 Oct 2010 16:53:00 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28344 Received: (qmail 23811 invoked from network); 12 Oct 2010 16:52:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) X-Authentication-Warning: pwslap01u.europe.root.pri: pws owned process doing -bs To: zsh-workers@zsh.org (Zsh hackers list) Subject: print -D and ${(D)} quoting X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.1.1 Date: Tue, 12 Oct 2010 17:52:47 +0100 Message-ID: <4637.1286902367@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 12 Oct 2010 16:52:50.0099 (UTC) FILETIME=[E78C3830:01CB6A2D] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-10-90-03 (www.mailcontrol.com) on 10.68.0.115 I noticed, via cdr, that the file "/home/pws/with space" turned into "~/with space" when you used "print -D". This seems to me wrong --- as it stands, the first part of the string needs to be used literally when passed to the shell as an argument for re-evaluation, while the second part needs to be quoted or it will be split into two words. So the result is inconsistent and there's no easy rule by which to interpret the resulting output. This isn't specific to space, it's true of any special character. As I was thinking about fixing this it occurred to me that most of the time I can fix it by using tricks with the parameter expansion (D) flag, although the (D) flag only got added in 28025 in June, which I think is why I didn't use it before. They're not completely trivial to do consistently, however. Still, the real fix isn't necessarily trivial to do consistently, either, so that's why I'm asking about it. In particular, unless I reorder the code in bin_print(), "-D" processing happens after any stripping of backslash that happens because -r is not present. That looks the wrong way round, certainly if I implement the fix. What I mean is, the new behaviour after the basic fix to add quoting is this: % print -rD "/home/pws/with space" ~/with\ space (because of -r) % print -D "/home/pws/with space" ~/with\ space # actual result ~/with space # expected result on general moral principles So I think I should reverse the order of handling of -D and not--r. That may be easier said than done, the logic in bin_print() is somewhat tortuous. Presumably if I change print -D I should also change the (D) flag similarly. I think that's less of an issue because it's easy to nest the effects of parameter flags. Further, quote munging is a more familiar effect in parameter substitution than it is in "print" statements. Plan B would be just to change the (D) flag and use that in "cdr -l"; there's no release of the shell with (D) in yet. -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom