Way to create multiline comments in Bash?

后端 未结 8 542
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 04:59

I have recently started studying shell script and I\'d like to be able to comment out a set of lines in a shell script. I mean like it is in case of C/Java :



        
8条回答
  •  感情败类
    2020-12-04 05:23

    Simple solution, not much smart:

    Temporarily block a part of a script:

    if false; then
        while you respect syntax a bit, please
        do write here (almost) whatever you want.
        but when you are
        done # write
    fi
    

    A bit sophisticated version:

    time_of_debug=false # Let's set this variable at the beginning of a script
    
    if $time_of_debug; then # in a middle of the script  
        echo I keep this code aside until there is the time of debug!
    fi
    

提交回复
热议问题