Inline comments for Bash?

前端 未结 8 919
深忆病人
深忆病人 2020-12-07 13:28

I\'d like to be able to comment out a single flag in a one-line command. Bash only seems to have from # till end-of-line comments. I\'m looking at tricks like:<

8条回答
  •  春和景丽
    2020-12-07 14:01

    For disabling a part of a command like a && b, I simply created an empty script x which is on path, so I can do things like:

    mvn install && runProject
    

    when I need to build, and

    x mvn install && runProject
    

    when not (using Ctrl + A and Ctrl + E to move to the beginning and end).

    As noted in comments, another way to do that is Bash built-in : instead of x:

    $  : Hello world, how are you? && echo "Fine."
    Fine.
    

提交回复
热议问题