bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About `M-C-e` expand result `'` failed


From: Chet Ramey
Subject: Re: About `M-C-e` expand result `'` failed
Date: Fri, 2 Feb 2024 10:09:53 -0500
User-agent: Mozilla Thunderbird

On 2/2/24 8:12 AM, Mike Jonkmans wrote:
On Thu, Feb 01, 2024 at 08:14:34PM -0500, Chet Ramey wrote:
On 1/31/24 6:05 PM, Mike Jonkmans wrote:

The first sentence under EXPANSION may make you think otherwise:
    Expansion is performed on the command line after it has been split into 
words.
    There are seven kinds of expansion performed: brace expansion,
    tilde expansion, parameter and variable expansion, command substitution,
    arithmetic expansion, word splitting, and pathname expansion.
The third sentence, after this, corrects this:
    After these expansions are performed, quote characters present in the 
original
    word are removed unless they have been quoted themselves (quote removal).
That sentence could also be placed right after the first.
I can rearrange things, but it seems clear already.

"There are seven kinds of expansion..." then three sentences later comes
quote removal. The reader may wonder whether quote removal is an expansion.

OK, then how about we enumerate the word expansions without numbering them.

That question pops up in the description of shell-expand-line:
    Expand the line as the shell does. This performs alias and history
    expansion as well as all of the shell word expansions.

This got changed about a year ago in the devel branch, the result of
https://lists.gnu.org/archive/html/bug-bash/2023-03/msg00031.html .
The current text reads

shell-expand-line (M-C-e)
        Expand  the line by performing shell word expansions.  This per-
        forms alias and history expansion, $'string' and $"string" quot-
        ing, tilde expansion, parameter and variable  expansion,  arith-
        metic expansion, word splitting, and quote removal.  See HISTORY
        EXPANSION below for a description of history expansion.


Maybe it is confusing that a (quote) removal is an expansion. Oh well.

What is the logic here?


Returning to `shell-expand-line'.
As end user I would expect that, running shell-expand-line then accept-line,
would do the same as just an accept-line.
Why would you expect this? You have deliberately introduced an extra
expansion step, similar to using `eval'.

I might expect that, because it would be useful to see what is going to be
executed.

I don't get this part. A desire is not an expectation. Why would you think
what you see is not what readline returns? There's no difference between
what you see on the line after expansion and you having typed it in
yourself. If you want to inhibit expansion of part or all of the just-
expanded line, you have the opportunity to quote those parts you don't want
expanded.

If you don't want the expanded line to be what's returned, undo the
editing operation after you look at the results. You can't undo any
side effects of the expansion, of course.


Then after review of the expansion, I could accept it.

Then undo the editing operation and let the expansions happen all over
again as part of command execution.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]