[Top][All Lists]

[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: Fri, 10 Jun 2022 10:14:29 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

On 6/9/22 8:37 PM, Luciano wrote:

On Wed, Jun 08, 2022 at 05:49:52PM -0400, Greg Wooledge wrote:
You could create a wrapper script, put it in your $HOME/bin/ directory
(and make sure that's in PATH), and then set EDITOR to that wrapper.
That should be much more reliable, especially if other programs also
use $EDITOR (which they might).
Yes, I think that's the most reasonable thing to do, and I'm going to do

It's consistent with what POSIX specifies.

On Thu, Jun 09, 2022 at 11:40:26AM -0400, Chet Ramey wrote:
The edit-and-execute-command key binding runs

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

[...] while the fc command without options runs (internally)

Well that explains it!  is there a reason why fc -e is used here for C-x C-e
instead of just plain "${VISUAL:-${EDITOR:-emacs}}" ?

I'm not sure I understand the question. You need to invoke fc to get the
right behavior: get a line from the history list, edit it, and execute the
result. It's a waste to duplicate code to do the same thing.

The default editor string is different because `fc' is supposed to default
to $FCEDIT and it would be unexpected for the C-xC-e key binding to use
that if it's defined.

By the way, git seems to interpret the EDITOR variable in a way
consistent with C-x C-e, while the pass program as I said seems to just
execute $EDITOR, like fc. I wonder if POSIX leaves room for interpretation here.

POSIX says little about the value of EDITOR, but makes it an application
requirement (the same thing as a user requirement) for the argument to
`fc -e' to be "a utility name, subject to search via the PATH variable."
Since $FCEDIT is the default editor, the same requirement holds for it
after expansion.

It's historical convention that VISUAL and EDITOR are subject to the same
restriction, but they are not described separately in the POSIX Environment
Variables section. (And yes, historically they were different and had
different requirements.)

The POSIX utilities that use $EDITOR don't say much, either, but the mailx
description makes it clear that EDITOR needs to expand to a command name
("the name of a utility to invoke").

Anyway, any sane person would probably just follow Greg's advice.

It provides maximum flexibility.


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