Skip to content

Commit 4aaeec5

Browse files
committed
only run chmod to make file executable if needed
1 parent 2c0e621 commit 4aaeec5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ luac.out
3939
*.x86_64
4040
*.hex
4141

42+
# Test Scripts
43+
tests

lua/canter/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ local function run_current_file(runImmediately, opts)
7777
end
7878

7979
if shebang then
80-
vim.cmd("!chmod +x " .. filepath) -- Make the file executable
80+
local absolute_path = vim.fn.fnamemodify(filepath, ":p")
81+
if vim.fn.executable(absolute_path) ~= 1 then
82+
vim.cmd("!chmod +x " .. vim.fn.shellescape(filepath)) -- Make the file executable if needed
83+
end
8184
end
8285

8386
execute_command(cmd, wait, opts)

0 commit comments

Comments
 (0)