Draft
Conversation
This reverts commit cceba47.
Determine the original filename by inspecting the command line of the parent process in the proc filesystem.
f3d5d21 to
256e86b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
sudoeditorsudo -eto edit files.Main details of this approach:
PPid:line of/proc/self/status/proc/<ppid>/cmdlinewhich holds a list of arguments separated by null bytessudoeditorsudo -eat 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:
systemcallsI 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 viapscommands (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.