我刚开始使用cmder,我注意到当它启动时,它会发出一堆错误消息,如下所示:
The filename, directory name, or volume label syntax is incorrect.
'"C:\Program Files (x86)\cmder\config\profile.d\"Loading"' is not recognized as an internal or external command, operable program or batch file.我仔细研究了正在运行的各种启动文件,发现错误来自init.bat中的这个块(最初安装程序时cmder安装程序创建的那个块):
pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
call :verbose-output Calling "%CMDER_ROOT%\config\profile.d\%%x"...
call "%CMDER_ROOT%\config\profile.d\%%x"
)
popd发生的情况是,%%x正在传递profile.d目录中找到的任何文件的名称(最初没有,所以我添加了一个与其名称相呼应的空cmd文件)、单词“正在加载”以及一个空字符串。我修改了当前版本的init.bat的源代码来确定这一点,并尝试在“调用”部分周围添加一个条件,就像这样,这并不像我期望的那样工作:
pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
if "%%x" NEQ "" && "%%x" NEQ "Loading" (
call :verbose-output Calling "%CMDER_ROOT%\config\profile.d\%%x"...
echo "Calling %%x from init.bat..."
call "%CMDER_ROOT%\config\profile.d\%%x"
)
)
popd我有点纠结于如何修复它(我编写了很多Unix/Linux shell脚本,但几乎从未编写任何Windows批处理程序)。此外,init.bat的顶部是这样的:
:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED这是init.bat中的错误吗?这是我的设置导致的吗?我也在我的电脑上运行cygwin,这会对此有所贡献吗?
有没有人对这里发生了什么以及我能做些什么来修复它有什么建议?
附录:
"Magoo“建议这样改变:
如果"%%x“NEQ "”if "%%x“NEQ”正在加载“( ...
但这也不起作用;空字符串和"Loading“(实际上是"\"Loading")仍然有效。
pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
echo "Calling *%%x* from init.bat..."
if "%%x" NEQ "" IF "%%x" NEQ "Loading" (
call :verbose-output Calling "%CMDER_ROOT%\config\profile.d\%%x"...
call "%CMDER_ROOT%\config\profile.d\%%x"
)
)
popd下面是现在输出的内容:
Calling ** from init.bat...
The filename, directory name, or volume label syntax is incorrect.
Calling *"Loading* from init.bat...
'"C:\Program Files (x86)\cmder\config\profile.d\"Loading"' is not recognized as an internal or external command, operable program or batch file.附录2:
我想我已经想出了一个可能的解决方案,一个临时的解决方案,应该在init.bat被覆盖之前一直有效。如果我将有问题的代码块更改为以下代码块,它似乎可以正常工作:
pushd "%CMDER_ROOT%\config\profile.d"
for /f "usebackq" %%x in ( `dir /b *.bat *.cmd 2^>nul` ) do (
IF DEFINED x IF EXIST "%%x" (
call "%%x"
)
)
popd这仍然不能解释为什么首先会生成两个有问题的字符串("“和”Loading“),但我将满足于此……
发布于 2017-04-10 22:38:35
if "%%x" NEQ "" && "%%x" NEQ "Loading" (不会像你期望的那样工作。if非常简单:‘`if value op value dothis’
你需要
if "%%x" NEQ "" IF "%%x" NEQ "Loading" (也就是说,第二个if是第一个条件creating and and的dothis。
不过,我建议您提前使用echo %%x - -to查看正在处理的实际文件名。
至于它被覆盖了-好吧,如果你调整了它,作者在安装更新时会覆盖它-所以保存一个副本并重新应用你的更改。
https://stackoverflow.com/questions/43325622
复制相似问题