323323--- @return table | nil Lines of content , nil if failed
324324function M .read_file_tail (file_path , tail_lines )
325325 -- Use system tail command for efficiency
326- local cmd = string.format (' tail -n %d "%s" 2>/dev/null' , tail_lines , file_path )
326+ local cmd = string.format (' tail -n %d %s 2>/dev/null' , tail_lines , vim . fn . shellescape ( file_path ) )
327327 local result = vim .fn .system (cmd )
328328
329329 if vim .v .shell_error ~= 0 then
@@ -488,7 +488,7 @@ function M.preview_binary_file(file_path, bufnr, info, file)
488488
489489 -- Try to get more information about the binary file
490490 if vim .fn .executable (' file' ) == 1 then
491- local cmd = string.format (' file -b "%s" ' , file_path )
491+ local cmd = string.format (' file -b %s ' , vim . fn . shellescape ( file_path ) )
492492 local result = vim .fn .system (cmd )
493493 if vim .v .shell_error == 0 and result then
494494 result = result :gsub (' \n ' , ' ' )
@@ -502,7 +502,7 @@ function M.preview_binary_file(file_path, bufnr, info, file)
502502 table.insert (lines , ' Hex dump (first 1KB):' )
503503 table.insert (lines , ' ' )
504504
505- local cmd = string.format (' xxd -l 1024 "%s" ' , file_path )
505+ local cmd = string.format (' xxd -l 1024 %s ' , vim . fn . shellescape ( file_path ) )
506506 local hex_result = vim .fn .system (cmd )
507507 if vim .v .shell_error == 0 and hex_result then
508508 local hex_lines = vim .split (hex_result , ' \n ' )
0 commit comments