From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23242 invoked by alias); 27 Oct 2010 10:03:19 -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: 28372 Received: (qmail 21995 invoked from network); 27 Oct 2010 10:03:07 -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) Date: Wed, 27 Oct 2010 11:02:40 +0100 From: Peter Stephenson To: Mikael Auno , zsh-workers@zsh.org Subject: Re: Prefixed backslash removed when completing command Message-ID: <20101027110240.16941d1f@pwslap01u.europe.root.pri> In-Reply-To: <4CC7EB88.8020105@kth.se> References: <4BF51CF3.8010609@kth.se> <4CC7EB88.8020105@kth.se> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 27 Oct 2010 10:02:40.0830 (UTC) FILETIME=[177A05E0:01CB75BE] X-Scanned-By: MailControl A-06-00-00 (www.mailcontrol.com) on 10.68.1.112 On Wed, 27 Oct 2010 11:06:16 +0200 Mikael Auno wrote: > If I am not completely misunderstanding your reply, I think you > misunderstood my issue. My issue has nothing to do with either single > or double quotes (they are only there in the original message to > separate the examples from the rest of the text), but with the > backslash. No, you've misunderstood my reply. > When I try to tab complete something starting with a leading > backslash, e.g. \mpla, then it is completed to mplayer (without a > leading backslash) instead of \mplayer (with a leading backslash) as > I would expect. Yes, I realise that. Here's my reply rephrased. The internals of completion are complicated. There is no prospect of it ever being able to preserve quotations in a general way. In particular there is no prospect of it ever being able to retain backslashes that have no basic syntactic effect. Slight digression on what I mean by a "basic syntactic effect". Aliases are a special case as they are expanded on input, so things that are usually ignored in the usual shell grammar become significant; completion doesn't know anything about this. Completion just tries to muddle through and produce an expression that (ignoring the alias problem) is quoted in an appropriate way for the shell to process the word on the command line. If quoting is done using backslashes the only backslashes left will be those needed for special characters. Completion makes no attempt to try to remember how the original word looked and reconstruct it. However, if quoting is done with a single or double quote character at the start of the word, that form of quoting is preserved even if it's not (apparently) needed to quote special characters. In this case, completion remembers the whole word is quoted. This is much simpler than trying to remember what happens character by character. So if you really insist on having a backslash, you are stuck, as far as completion is concerned. (You still have the possibility of writing line editor, non-completion, functions to quote the word how you want.) However, *if* it happens to be the case that you are simply trying to ensure the word is quoted, somehow, you can get away with starting it with a single quote, and forget about the backslash. The single quote is preserved during completion, unlike the backslash, and a closing quote appended. So it all works, and you have completed a quoted word. I'm not aware of anywhere in the shell that requires you to quote a word as \mplayer rather than 'mplayer'. They should have the same effect in every case except the bizarre one where you have defined 'mplayer', including the quotes, as an alias. So if you started with a single quote (I know that's not what you asked about) it should do the right thing, or I'd like to hear why it doesn't. -- 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