1

bat 脚本 参数带等号问题 求解

 2 years ago
source link: https://www.v2ex.com/t/866945
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Windows

bat 脚本 参数带等号问题 求解

  freakxx · 58 分钟前 · 203 次点击
PS C:\Users\x\Desktop> type .\test.bat
@echo all : %*
@echo arg1 : %1
@echo arg2 : %2

PS C:\Users\x\Desktop> .\test.bat "aaa=bbb,ccc" "ddd;eee"
all : aaa=bbb,ccc ddd;eee
arg1 : aaa
arg2 : bbb

切到 win 去玩了下脚本,发现参数里带等号也会直接被解析,请问这种情况,怎么直接传进去一个带等号的字符串不被解析

或者我应该怎么取参数才是正确的

第 1 条附言  ·  18 分钟前

直接使用#6 的处理方法
用单引号再包一层进行传递

> .\xxx.bat '"aaa=bbb,ccc"' '"ddd;eee"'

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK