开发者

How to turn off ".\" in powershell when execute local command?

By default Powershell r开发者_开发百科equires ".\" before any local executable. So to execute local command in Powershell you need type something like

.\foo arg1

How to turn requirement to type ".\" off, so I can run just like

foo arg1

And what is the correct name of the ".\"?


.is the current directory and \is the path separator. That means .\foo is the relative path to the foo program.

If .is not included in your PATH environment variable, you have to specify it as above. To avoid that, you could add . to your PATH variable. But as a rule of thumb, never do so, since it leads to security risks. Better use .\foo or even better provide the absolute path.


It is a security feature to make sure you run only the executables at the desired location. This ensures that you are running the right executable and not a hijacked one.

This is a language / shell implementation and you cannot turn it off, IMO.


you can't turn it off, however you could turn your could put your functions in a module (or even a script you load somewhere else), and load that then at least calling those functions looks nicer (without the .\foo


perhaps . isn't in the path, the tabcompletion function detect that, so if you write foo[TAB] then automatically is expanded to .\foo. For this reason i don't see where is the "extra work" putting the dot and the slash if tabcompletions takes care of that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜