更新时间:2022-06-21 06:38:36
那些奇怪的变量被称为参数扩展.它们允许您将变量解释为文件/目录的路径,并直接从该路径解析内容.
Those weird variables are called parameter extensions. they allow you to interpret a variable as a path to a file/directory and directly resolve things from that path.
例如,如果 %1
是文件 dir123456\file.txt
的路径,
For example, if %1
is a path to a file dir123456\file.txt
,
%~f1
是 file.txt
的完全限定路径,%~p1
是包含目录dir123456
的路径,%~s1
是短名称格式的路径 dir123~1\file.txt
,%~f1
is the fully qualified path to file.txt
,%~p1
is the path to the containing directory dir123456
,%~s1
is the path in short name format dir123~1\file.txt
,此外,%0
始终设置为当前正在运行的脚本的路径.所以:
Also, %0
is always set to the path of the currently running script. So:
%~fs0
是到当前脚本的全限定路径,采用短名称格式,%%~dpsi
是将 FOR
变量 %%i
手动扩展为一个盘符 (d
code> 选项)后跟包含文件夹的路径(p
选项),采用短格式(s
选项).%~fs0
is the fully qualified path, in short name format, to the current script,%%~dpsi
is the manual expansion of the FOR
variable %%i
to a drive letter (d
option) followed by the path the containing folder (p
option), in short format (s
option).现在,这个看起来很奇怪的代码块是 KB833431 的一种解决方法,其中 %~dps0
命令不会不给你当前脚本文件夹的路径(短格式),尽管它应该.这已在 XP SP2 中修复.
Now, this weird looking block of code is a workaround for KB833431 in which the %~dps0
command does not give you the path to the folder of the current script (in short format) although it should. This was fixed in XP SP2.
它似乎是从 scala.bat
的完全限定路径手动重建到 scala bin
目录的完全限定路径,然后只是获取该目录的父目录,这应该是一个有效的 _SCALA_HOME
.
It seems to be reconstructing manually the fully qualified path to the scala bin
directory from the fully qualified path to scala.bat
, and then just getting that directory's parent, which should be a valid _SCALA_HOME
.