![](/img/trans.png)
[英].homestead nor Homestead.yaml is showing up after running bash init.bat
[英]cmder startup: bug in init.bat?
我剛開始使用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文件,該文件僅呼應其名稱),單詞“ Loading”也是如此作為一個空字符串。 我修改了最新版本的init.bat的源來確定這一點,並且我嘗試在“ call”部分放置一個條件,就像這樣,它不能像我期望的那樣起作用:
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中的錯誤嗎? 這與我的設置有關嗎? 我也在我的PC上運行cygwin,這是否有助於實現這一目標?
有人對這里發生的事情以及我可以采取的解決措施有任何建議嗎?
附錄:
“ Magoo”建議此更改:
if“ %% 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”),但是我會為此解決...
if "%%x" NEQ "" && "%%x" NEQ "Loading" (
不會如您所願。 if
很簡單,如果if op value做this
你需要
if "%%x" NEQ "" IF "%%x" NEQ "Loading" (
也就是說,第二個if
就是第一個創建and
條件的dothis
。
我建議您雖然先echo %%x
x--以查看正在處理的實際文件名。
至於它的被覆蓋-如果您進行調整,那么作者在安裝更新時將覆蓋它-因此請保存副本並重新應用您的更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.