Restore sudoedit filetype detection #104
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a proposal to fix #31 by using the proc filesystem to determine the original filenames from the command line of the parent process when using
sudoedit
orsudo -e
to edit files.Main details of this approach:
PPid:
line of/proc/self/status
/proc/<ppid>/cmdline
which holds a list of arguments separated by null bytessudoedit
orsudo -e
at the beginning of the parent command line, and setting an offset to file arguments starting indexIt is a follow-up on previous discussions on #31 and #79, and in response to
in this comment.
While I’m lacking the exact criteria for a solution to be considered “robust” for vim-eunuch purposes, this approach does address the known concerns from previous attempts:
system
callsI tested this on successfully on:
I'm also not a Mac OS X user, but it does not seem to have a procfs out-of-the-box that we could use in a similar manner. There are apparently third-party solutions like kimtopley/ProcFS which sounds like a weird dependency, or we may opt for a
system()
based approach viaps
commands (with the remark that on previous attempts this was discouraged).Anyone testing should be aware that this seems to conflict with current latest version of vim-polyglot, so best to disable that before trying this patch.
I’m opening it as a draft pull request only at first in order to learn more and gather further feedback.
My main questions at this stage:
Please review, and let me know how to improve it further. I'm also happy to reorganize commits into a different history if desired.