MyCommand的源码与路径

huangapple go评论63阅读模式
英文:

MyCommand's Source vs Path

问题

$MyInvocation.MyCommand.Source.Path在什么情况下不同?

根据文档,其中一个"获取脚本文件的路径",而另一个"获取此命令的源",但每当我看到其中一个有值时,另一个也具有相同的值。

这只是与此特定自动变量的巧合,其他ExternalScriptInfo是否更复杂?

英文:

Under what circumstances does $MyInvocation.MyCommand's .Source differ from .Path?

One "Gets the path to the script file." whilst the other "Gets the source of this command." according to the docs, but whenever I've ever seen one populated the other has the same value.

Is this just a coincidence with this specific automatic variable and other ExternalScriptInfos are more complex?

答案1

得分: 1

如评论中所提到的,对于 ExternalScriptInfo 实例,PathSourceDefinition 属性始终返回底层路径 - 可以通过查看此处的源代码进行验证。

对于 ApplicationInfo 也是一样的情况,请查看此处的源代码

英文:

As mentioned in the comments, for ExternalScriptInfo instances, the Path, Source and Definition properties always return the underlying path - as can be verified by inspecting the source code here.

The same goes for ApplicationInfo.

huangapple
  • 本文由 发表于 2023年6月16日 01:25:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76484140.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定