POSIX find warn when using '-printf' flag (#110)

main
bhagwan 3 years ago
parent 120a097205
commit 4b59a5d31d

@ -9,6 +9,16 @@ local libuv = require "fzf-lua.libuv"
local M = {}
local function POSIX_find_compat(opts)
local ver = utils.find_version()
-- POSIX find does not have '--version'
-- we assume POSIX when 'ver==nil'
if not ver and opts:match("%-printf") then
utils.warn("POSIX find does not support the '-printf' option." ..
" Install 'fd' or set 'files.find_opts' to '-type f'.")
end
end
local get_files_cmd = function(opts)
if opts.raw_cmd and #opts.raw_cmd>0 then
return opts.raw_cmd
@ -20,6 +30,7 @@ local get_files_cmd = function(opts)
if vim.fn.executable("fd") == 1 then
command = string.format('fd %s', opts.fd_opts)
else
POSIX_find_compat(opts.find_opts)
command = string.format('find -L . %s', opts.find_opts)
end
return command

@ -482,4 +482,9 @@ function M.git_version()
return tonumber(out:match("(%d+.%d+)."))
end
function M.find_version()
local out, rc = M.io_systemlist("find --version")
return rc==0 and tonumber(out[1]:match("(%d+.%d+)")) or nil
end
return M

Loading…
Cancel
Save