Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(terminal): failure to remove .lock file #233

Merged
merged 1 commit into from
May 20, 2024

Conversation

luxstudio90
Copy link
Contributor

When the runner/executor is set to terminal the removal of the .lock file fails if the user has setup a shell alias for the rm(1) command that requires confirmation (e.g.: alias rm='rm -iv').

In such case, the runner/executor does not finish and waits indefinitely for user confirmation:
remove ~/.local/share/nvim/cmake-tools-tmp/.lock?

This PR bypasses any alias of rm(1) command and also uses the -f flag.

When the runner/executor is set to `terminal` the removal of the .lock
file fails if the user has setup a shell alias for the `rm(1)` command that
requires confirmation (e.g.: alias rm='rm -iv').

In such case, the runner/executor does not finish and waits indefinitely
for user confirmation: remove ~/.local/share/nvim/cmake-tools-tmp/.lock?

This PR bypasses any alias of `rm(1)` command and also uses the `-f` flag.
@@ -542,7 +542,7 @@ end
local get_command_handling_on_exit = function()
return "echo $? > "
.. get_last_exit_code_file_path() -- write exitcode to file
.. " && rm "
.. " && \\rm -f "
Copy link
Owner

Choose a reason for hiding this comment

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

Why is there a \\?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the shortest way to bypass an alias in the shell.

There are multiple ways to do this (with pros and cons):

  • prefix a back slash to disable the alias: \rm -f
  • use "command": command rm -f (will also cover the case when the user has a custom function called rm() but some shells might not support it)
  • use the full path: /bin/rm -f (not guaranteed to be the same on all distros)
  • quote the command: "rm" or 'rm'

command rm -rf will also be a good alternative.

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, this makes sense.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this breaks the fish shell.
I'd suggest to use the command rm -f alternative instead

@Civitasv Civitasv merged commit 8ad97dd into Civitasv:master May 20, 2024
2 checks passed
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.

3 participants