Back to Shell

Comments

docs/expressions/comments.html

1.9.151.1 KB
Original Source

Comments

Comments can be used to explain Shell code, and to make it more readable. It can also be used to prevent execution Shell code. Comments can be singled-lined or multi-lined.

Single-line Comments

Single-line comments start with two forward slashes (//).
Any text between // and the end of the line is ignored (will not be executed).

This example uses a single-line comment before a line of code:

dynamic 
{
	// This is a comment
	item(title='Hello World!')

	//item(title='Hello World!')
}

This example uses a single-line comment at the end of a line of code:

dynamic 
{
    item(title='Hello World!') // This is a comment
}
Multi-line Comments

Multi-line comments start with /* and ends with */.
Any text between /* and */ will be ignored.

dynamic
{
	item(title='Hello,/* multiple-lines comment inside */ world')

	/*
	item(title='test item 1')
	item(title='test item 2')
	*/
}

Single or multi-line comments?
It is up to you which you want to use. Normally, we use // for short comments, and /* */ for longer.