这是我的第一个批处理脚本。我试图逃避%char,因此不用作变量。 Double %%在使用start时有效,但是当我使用%% with call时,它输入空的空格和函数缺少参数。
使用通话时有没有办法逃脱%?
call wp rewrite structure %%postname%% << FAILED
start wp rewrite structure %%postname%% << OK
我只是想知道为什么与#34; start&#34;按预期工作,&#34;打电话&#34;错过了一个论点。两者都使用额外的%char来逃避百分号。
答案 0 :(得分:7)
我认为你的“确定”行是正常的,因为你想要文字%postname%
,并且你认识到必须通过在批处理文件中加倍来转义百分比文字。
如果不加倍,则%postname%
会扩展为环境变量postname的值(如果未定义,则为空字符串)。
CALL导致百分比被评估两次。第一轮百分比展开会将%%postname%%
转换为%postname%
。这就是你想要的。但是,然后由CALL启动的第二轮导致%postname%
扩展为变量值。
解决方案很简单,第二次加倍百分比:
call wp rewrite structure %%%%postname%%%%
答案 1 :(得分:3)
你试过吗
call wp rewrite structure %%%%postname%%%%