Shell script multi-line comment

后端 未结 5 1889
傲寒
傲寒 2021-01-03 09:32

I am having a large shell script file. At times while doing modification I want to comment out part of it. But commenting line as shown in the below example is giving me e

5条回答
  •  孤街浪徒
    2021-01-03 10:00

    Using here docs to comment code is safe and elegant like this:

    : <<'EOT'
    Example usage of the null command ':' and the here-document syntax for a 
    multi-line comment.  If the delimiter word ('EOT' here) is quoted, the 
    here-document will not be expanded in any way.  This is important, as 
    an unquoted delimiter will result in problems with unintended potential 
    expansions.  All of this here-doc text is redirected to the standard input 
    of :, which does nothing but return true.  
    EOT
    

提交回复
热议问题