How to split double quoted line into multiple lines in Windows batch file?

后端 未结 5 1637

Long commands in Windows batch files can be split to multiple lines by using the ^ as mentioned in Long commands split over multiple lines in Windows Vista batc

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 04:23

    The clear advantage of @solvingJ's method over the variants of Jeb is that it is quite obvious what happens and that there is a spatial seperation of on the left hand the ugly cmd stuff and on the right the actual content. And it can be improved in readability by putting more spaces between the left and the right part:

    set      CMD=   docker run --rm
    set CMD=%CMD%     --platform=linux
    set CMD=%CMD%     -v %CD%:/work
    set CMD=%CMD%     dockcross/%IMAGE_NAME%
    set CMD=%CMD%     /bin/sh -c
    set CMD=%CMD%       "mkdir build-%IMAGE_NAME% &&
    set CMD=%CMD%       cd build-%IMAGE_NAME% &&
    set CMD=%CMD%       cmake .. &&
    set CMD=%CMD%       cmake --build ."
    

    Unfortunately it is not possible to demonstrate this in a comment because multiple spaces are reduced to one there. So I do in an answer what is actually just a comment to @solvingJ's answer, which I consider the best.

提交回复
热议问题