bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistency between fc and C-x C-e


From: Chet Ramey
Subject: Re: Inconsistency between fc and C-x C-e
Date: Thu, 9 Jun 2022 11:40:26 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

On 6/8/22 5:06 PM, Luciano wrote:
Hi!
I had the terrible idea to set my EDITOR variable to something too
complex. I had to pass some options with whitespace to vim, so i decided
to use `eval`. I managed to get something working, but the way the
EDITOR variable is interpreted isn't consistent
to provide an example, if one sets EDITOR in .bashrc to:
EDITOR="eval vim --cmd \" set statusline=HI-FROM-\\\$EDITOR laststatus=2  \" --  
"
then doing 'fc' works fine, (I get the "HI-FROM-$EDITOR" message on the
status line"), but C-x C-e seems to wipe out the ' \" ' arguments altogether,
leaving eval with only loose words after '--cmd'.
C-x C-e seems to have an extra pass with character escaping, doubling
every \ character makes C-x C-e work as intended, but now fc doesn't
work anymore!

The edit-and-execute-command key binding runs

fc -e "${VISUAL:-${EDITOR:-emacs}}"

(since it's in emacs mode) as a shell command, which means the shell parses
and executes it, while the fc command without options runs (internally)

"${FCEDIT:-${EDITOR:-vi}}"

fc builds a new command line from its options and has the shell parse and
execute it.

The first variant (C-xC-e) will therefore have the arguments expanded
before fc sees the command, and again when fc executes the command it
constructs.

The second will have $EDITOR expanded once, as part of the command fc
constructs.

--
``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/



reply via email to

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