DOS Multiline batch command. How to add comments between arguments?

你。 提交于 2021-02-10 12:01:23

问题


Id like to add comments like this:

makecert -r ^        // This means SelfSigned
         -pe ^       // Private key is exportable
         -a sha512 ^ // The algoritm
         ...

Is this possible? How?


回答1:


Nothing official, but there is a simple and very effective hack - use undefined variables. At least one = is added to guarantee that the content cannot be a valid variable name, since the character cannot be used in a variable name. I use one at the beginning and end just for symmetry. Also, the comment cannot contain % or :. Finally, the line continuation ^ character must be the last character in the line.

makecert -r        %= This means SelfSigned     =% ^
         -pe       %= Private key is exportable =% ^
         -a sha512 %= The algoritm              =% ^
         ...

Note - this only works within a batch script. It cannot be used on the command line.



来源:https://stackoverflow.com/questions/28697592/dos-multiline-batch-command-how-to-add-comments-between-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!