lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 7/21/08, Xu Wang <xu4wang@gmail.com> wrote:
> Dear lua list,
>
> See below for a test:
>
> D:\test>lua
> Lua 5.1.2  Copyright (C) 1994-2007 Lua.org, PUC-Rio
> > cmd1=[["C:\Program Files\TortoiseSVN\bin\subwcrev" .\ "addnb.v29.ace" "D:\ace\addnb.v29.ace"]]
> > os.execute(cmd1)
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file.
> > cmd2=[["C:\Program Files\TortoiseSVN\bin\subwcrev" .\ addnb.v29.ace D:\ace\addnb.v29.ace]]
> > os.execute(cmd2)
> SubWCRev: 'D:\wangxu\WorkData\Kuwait_USR6_USR6.1\movie\'
> Last committed at revision 18
> Mixed revision range 17:18
> >
>
> cmd1 is error but cmd2 can be executed sucessfully. why?
>
> Regards,
> Xu
>

Windows is very peculiar when it comes to quoting command lines. Try
"help cmd" in a command window to get into details.

The "proper" way to give a command line to os.execute() on Windows is
to double-quote each of the program name and all its arguments, and
then wrap double-quotes around the whole thing. For example:

cmd = [["C:\Program Files\TortoiseSVN\bin\subwcrev" ".\"
"addnb.v29.ace" "D:\ace\addnb.v29.ace"]]
os.execute([["]] .. cmd .. [["]])

Robby