command standard output is not ":read" if command returns a non-zero result
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the :read and :r! command handling into the command execution path, then inspect how stdout is treated when the process exits with a non-zero result. Reproduce the Dart example or an equivalent command and compare it with the working range form. Done means stdout is inserted into the buffer despite the exit status, with coverage for the non-zero-result case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100