Zsh Mailing List Archive
Messages sorted by:
Re: Prefixed backslash removed when completing command
- X-seq: zsh-workers 28373
- From: Mikael Auno <auno@xxxxxx>
- To: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- Subject: Re: Prefixed backslash removed when completing command
- Date: Wed, 27 Oct 2010 12:41:05 +0200
- Cc: zsh-workers@xxxxxxx
- In-reply-to: <20101027110240.16941d1f@xxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <4BF51CF3.8010609@xxxxxx> <4CC7EB88.8020105@xxxxxx> <20101027110240.16941d1f@xxxxxxxxxxxxxxxxxxxxxxxxx>
On 2010-10-27 12:02, Peter Stephenson wrote:
On Wed, 27 Oct 2010 11:06:16 +0200
Mikael Auno<auno@xxxxxx> 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
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
Thank you for this insight,
Messages sorted by: