Block Comments in a Shell Script

后端 未结 12 1195
小鲜肉
小鲜肉 2020-12-02 03:36

Is there a simple way to comment out a block of code in a shell script?

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 04:19

    I like a single line open and close:

    if [ ]; then ##
        ...
        ...
    fi; ##
    

    The '##' helps me easily find the start and end to the block comment. I can stick a number after the '##' if I've got a bunch of them. To turn off the comment, I just stick a '1' in the '[ ]'. I also avoid some issues I've had with single-quotes in the commented block.

提交回复
热议问题