From 0e26934613d636795c28de2dc528c82d58b04f17 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 13 Jul 2026 13:11:31 +0000 Subject: [PATCH] audit: replace vim.fn.system shell pipeline with vim.system in treesitter.lua vim.fn.system() with shell metacharacters (2>&1, |) depends on $SHELL and is harder to reason about. vim.system() (added in Neovim 0.10) spawns the process directly, captures stdout/stderr separately, and is the idiomatic modern API. No behaviour change: glibc version detection logic is identical. --- lua/config/treesitter.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua index 75f9dd2..9c3a400 100644 --- a/lua/config/treesitter.lua +++ b/lua/config/treesitter.lua @@ -40,15 +40,14 @@ local parser_repos = { -- this function needs to be updated occasionally, as of 260130, glibc should be at least 2.30 local function get_glibc_version() - local result = vim.fn.system("ldd --version 2>&1 | head -n1") - if vim.v.shell_error ~= 0 then + local result = vim.system({ "ldd", "--version" }, { text = true }):wait() + if result.code ~= 0 then return nil end - local version = result:match("(%d+%.%d+)%s*$") or result:match("GLIBC (%d+%.%d+)") - if version then - return tonumber(version) - end - return nil + local output = result.stdout ~= "" and result.stdout or result.stderr + local first_line = output:match("^([^\n]*)") + local version = first_line:match("GLIBC (%d+%.%d+)") or first_line:match("(%d+%.%d+)%s*$") + return version and tonumber(version) or nil end local function has_tree_sitter_cli()