Given this command:
ex -sc '%!alfa' -cx file
I get this result:
sh: alfa: command not found
which is to be expected. However an unintended side effect of this is that the file is emptied and saved.
Can this command be modified so that if the external command is not found, then Vim bails instead of saving an empty file?
echo data > file1 ; vim -u NONE -c "ex -sc '%\!alfa' -cx file2" file1
-u NONE
(which is a good idea when debugging something). In general i'm confused about what exactly you are performing just as much you are confused about what i am performing. But you are the one with a question, can i ask you to elaborate exactly what you're running? Is it a command-mode ex (a:
normal-mode command)? Or you're entering ex-mode? Or you're running ex from the command line?ex
command invim
behaves differently from running theex
binary. Not all systems haveex
as a call tovim -e
. But now I get you. I can replicate it withvim -u NONE -e -sc '%!alfa' -cx file
(i believe that is the portable command, not sure if-u NONE
is needed)vim -e -scx file
works as expected but evenvim -e -sc '%!echo >/dev/null' -cx file
writes the empty file.