开发者

Can anybody explain this strange variable expansion behaviour by cmd.exe with gzip?

I am running into the following problem with gzip.exe, be it from UnxUtils or from GnuWin32:

set gzip=.\util\gzip.exe
%gzip% test.txt
%gzip% test2.txt

The second gzip command will issue a warning like the following:

gzip: .\util\gzip.exe.gz already exists; do you wish to overwrite (y or n)?

So: gzip tries to compress itself (and it still compresses test2.txt). It is like if the command line was: .\util.gzip.exe .\util.gzip.exe test2.txt.

However, when in my batch my variable is not named gzip, then it works correctly.

set gzip_prg=.\util\gzip.exe
%gzip_prg% test.txt
%gzip_prg% test2.t开发者_Python百科xt

I do not understand at all how the choice of a variable name can have an influence on the command line that is run after expansion.

In short, my batch script behaves in a different way when I change the name of a variable!

Has anyone an explanation for this phenomenon?


I found the answer myself.

gzip.exe reads the GZIP environment variable that helps setting options.

Here, gzip reads the environment variable and considers therefore that it has to compress itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜