Skip to content

Conversation

@benjosua
Copy link
Contributor

@benjosua benjosua commented Jan 21, 2026

Replace io.popen() with vim.system() for safer command execution and better error handling.

Copilot AI review requested due to automatic review settings January 21, 2026 22:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request replaces the use of io.popen with vim.system throughout the codebase for executing external commands. This change improves security by avoiding shell injection risks, provides better error handling, and aligns with modern Neovim API best practices.

Changes:

  • Replaced io.popen with vim.system in git diff execution for safer command handling
  • Removed the exec helper function and converted all Unix process discovery commands to use vim.system
  • Updated error handling in Windows PowerShell execution and Unix process walking to handle command failures more gracefully

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lua/opencode/context.lua Updated git_diff() to use vim.system instead of io.popen with improved error handling
lua/opencode/cli/server.lua Removed exec() helper; converted get_processes_unix(), is_descendant_of_neovim() to use vim.system; adjusted PowerShell error handling in get_processes_windows()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@benjosua benjosua force-pushed the use-vim-system-instead-of-io-popen branch from e205bb5 to 97e7ea4 Compare January 21, 2026 23:11
@NickvanDyke
Copy link
Owner

Nice, tyvm for this!

Now that we have more information about the result, could you check for a non-zero codes and error(<cmd> failed with <code>\nstderr:\n<stderr>) in that case? Just to save us from some silent failure headaches in the future 😀

Signed-off-by: benjosua <ben.script@protonmail.com>
@benjosua benjosua force-pushed the use-vim-system-instead-of-io-popen branch from 97e7ea4 to cb201b6 Compare January 21, 2026 23:43
@NickvanDyke NickvanDyke merged commit ddd6583 into NickvanDyke:main Jan 23, 2026
2 checks passed
@benjosua benjosua deleted the use-vim-system-instead-of-io-popen branch January 23, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants