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 c...@case.edu http://tiswww.cwru.edu/~chet/