Is it possible to run WSL Bash in non-interactive mode?

后端 未结 2 388
醉酒成梦
醉酒成梦 2021-01-16 12:48

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

2条回答
  •  情歌与酒
    2021-01-16 13:04

    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.

提交回复
热议问题