Vim
Vim copied to clipboard
command standard output is not ":read" if command returns a non-zero result
Describe the bug
Executing a :read command that returns with ERRNO not equal to zero does not read stdout as it should. It just throws notice:
CommandLine: Error executing cmd=r! ./bin/pob. err=Error: Command failed: ./bin/pob.
To Reproduce
- Make a binary printing to stdout and then returning a not zero result. Dart example tested:
// > pob.dart; dart compile exe -o bin/pob bin/pob.dart
import 'dart:io';
void main() {
print('Stdout NOT taken!');
exit(33);
}
- do
:r! ./bin/pob - See error "CommandLine: Error executing cmd=r! ./bin/pob. err=Error: Command failed: ./bin/pob" notice .
Expected behavior Output of command should be read into the buffer. Regardless of process returning non-zero. This is a normal behavior of scripts that are meant for both in pipe and interactive work.
Workaround
Pipe for region behaves.
You can read output with :adr,adr! where adr is set at existing empty line.
So as a workaround just use :7,7! command instead of :r! in 7 line.
Environment (please complete the following information):
- Extension (VsCodeVim) version: 1.23.1
- VSCode version: 1.69.1
- OS: macOS 12.3
Additional context
"terminal.integrated.shellIntegration.enabled": false but settings UI says "Enabled".
I also experienced an editor keyboard input hang (with cmdline hanging) with above reported :read command outputs bug. Output was in range of a few kB. Just notice here for posteriority, as I have no time to make a reproduction case; then this hang is likely an effect of command stdout not being properly disposed.
Edit: hanging vim cmdline confirmed with way less output.