Closed lorenzleutgeb closed 10 months ago
It's not an 'arbitrary constraint'. Parsing command line arguments is very complex (like, it's a large chunk of shell programs' functionality). Unless I replace the Shell setting with a variable-sized list of inputs to basically ask users to manually do this, which is probably gonna be a lot more confusing and user unfriendly, I simply cannot translate a single string to a Command::new
call easily (otherwise Command::new
would have already supported that, why bother asking for a list of arguments? :) ).
For example, how do you parse /bin/weird-shell --title="Hello, \"World\"" -c <current command template here> -- 'foo bar' foo bar
?
And btw you don't need a Bash-compatible shell. It only needs to be POSIX-compatible. People also had positive experience with pwsh
under Windows: #78.
Description
Your code works under the assumption that people will choose a bash compatible shell for the "shell" configuration parameter. This is evidenced by the following constants:
https://github.com/Frederick888/external-editor-revived/blob/26cab0a4e5006202df3d25d110133a7e22e03ec7/src/main.rs#L16-L17
I'd argue that this is an arbitrary constraint, and you should consider lifting it, allowing people to do as they please. By that, I mean that you should remove insertion of
DEFAULT_SHELL_ARGS
. Rename the configuration parameter to e.g. "program" and directly pass it toCommand::new
.People that use could still do so by specifying (the path to) Bash as program, and using e.g.
-C "vim /path/to/temp.eml"
as their "command template".For example, I am personally using Visual Studio Code as editor. I don't actually need MinGW or Bash to do that. But I spend quite some time and look at the source code to figure out a work around (which is linked below).
You could still include predefined configurations with the extension.
Environment
external-editor-revived --version
output: 0.6.0Configuration
Shell:
C:\Users\lorenz\external-editor-revived.bat
Command template:/path/to/temp.eml
Contents of
external-editor-revived.bat
: https://gist.github.com/lorenzleutgeb/2c76e24f15ea70d4f1102bbd5111d4e2