zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Auno <auno@kth.se>
To: Peter Stephenson <Peter.Stephenson@csr.com>
Cc: zsh-workers@zsh.org
Subject: Re: Prefixed backslash removed when completing command
Date: Wed, 27 Oct 2010 12:41:05 +0200	[thread overview]
Message-ID: <4CC801C1.1020109@kth.se> (raw)
In-Reply-To: <20101027110240.16941d1f@pwslap01u.europe.root.pri>

On 2010-10-27 12:02, Peter Stephenson wrote:
> On Wed, 27 Oct 2010 11:06:16 +0200
> Mikael Auno<auno@kth.se>  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.

You are completely correct. I misunderstood your reply as I did not know 
that the backslash was at all related to quoting or that ordinary 
quoting had the same result as prefixing a command with a backslash with 
respect to suppressing alias expansion. Prefixing with single or double 
quotes works great, especially as the closing quote is appended 
automatically.

Thank you for this insight,
Mikael Auno


  reply	other threads:[~2010-10-27 10:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-20 11:28 Mikael Auno
2010-05-20 12:39 ` Peter Stephenson
2010-10-27  9:06 ` Mikael Auno
2010-10-27 10:02   ` Peter Stephenson
2010-10-27 10:41     ` Mikael Auno [this message]
2010-10-27 10:48       ` Peter Stephenson
2010-10-27 12:23         ` Štěpán Němec
2010-10-27 12:29           ` Mikael Magnusson
2010-10-27 12:49           ` PATCH: document more alias problems Peter Stephenson
2010-10-27 10:49       ` Prefixed backslash removed when completing command Mikael Magnusson
2010-10-27 15:43     ` Bart Schaefer

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=4CC801C1.1020109@kth.se \
    --to=auno@kth.se \
    --cc=Peter.Stephenson@csr.com \
    --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).