问题
One may want to use Bash on Windows in Task Scheduler or maybe as version-control hook scripts. Is it possible or supported?
If not, why? Is it a bug or a measure to prevent some issues?
回答1:
If I'm understanding your question correctly, the -c
option is what you're looking for. It allows you to directly invoke a Linux command.
For example, to open the man page for bash (perhaps in order to find out about the -c
option):
bash -c "man bash"
Note: You can leave off the quotes if you escape any spaces (e.g. bash -c man\ bash
), but it's often easier to just use the quotes, as the first unescaped space will lose the rest of your command.
e.g. bash -c man bash
will be interpreted the same as bash -c man
.
来源:https://stackoverflow.com/questions/45959560/is-it-possible-to-run-wsl-bash-in-non-interactive-mode