Run with internal flag when saving with sudo on Windows #3578
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.
The description of this pull request is written to try to summarize few details mentioned in #3541 and add others that have been found. Feedback, questions and suggestions are appreciated even if they are decided without too much thought or details cannot be understood well.
PowerShell is the only program available by default on Windows that can be used to write data in standard input to a file in place of
dd
, but a long script with around 10 lines has to be used when using PowerShell. Due to this, the command is changed to run micro itself with a new internal flag when saving using sudo on Windows.Using
ShellExecute
in micro was mentioned in #3541 but data cannot be written to the standard input of the process started. Running micro itself with an internal flag may be the least worst method but there are no programs I know that temporarily retrieve permissions, so I cannot check if the method is considered fine.I was saving
C:\test.txt
withファイル内容
as content inms932
/shift_jis
encoding when testing. There should be no text corruption when running micro again withmicro -encoding ms932 C:\test.txt
after file is saved. All programs below exceptrunas
worked and were checked if specifying arguments insucmd
has to be supported:runas
sudo
name can be added using installerCloses #3541