Shell Script Annotation _linux Shell

Source: Internet
Author: User
Tags mkdir

I. Single-select annotations

Lines that begin with "#" are comments that are ignored by the interpreter.

Copy Code code as follows:

#--------------------------------------------
# This is a script that automatically plays IPA, based on Webfrogs's ipa-build writing:
# Https://github.com/webfrogs/xcode_shell/blob/master/ipa-build

# Features: Automatically packaged for Etao iOS app, 14-channel IPA package
# Features: Automatic packaging, no need to enter any parameters
#--------------------------------------------

##### User Configuration area starts #####
#
#
# project root directory, it is recommended to put this script in the root directory of the project, there is no need to change the
# application name to ensure consistency with the Target_name.app name under Xcode product
#
##### User Configuration area End #####

Two or more lines of comment

What if, during the development process, a large segment of code needs to be annotated temporarily and then canceled? Each line with a # symbol is too laborious, you can put this paragraph to annotate the code in a pair of curly braces, defined as a function, no place to call the function, the code will not be executed, to achieve the same effect as the annotation. Example:

Copy Code code as follows:

Notexce () {
CP./a.txt./b.txt
mkdir-p {1,2,3}/{4,5,6}
echo "OK"
}

But if we need to comment on a large segment of the shell script, if we all add the # in front of each line, which is really not a very comfortable thing for us, then, in the shell, there is no way to use a C-like annotation/* ... to achieve a whole paragraph of the annotation effect? The notes were tested and found that the following method was OK.

Copy Code code as follows:

: <<! Eof!
CP./a.txt./b.txt
mkdir-p {1,2,3}/{4,5,6}
echo "OK"
! Eof!

You can even turn the shell of the annotation into a function to achieve the goal of not allowing execution. As in Example 2.

To comment out the shell multiline, there are also the following methods:

The first: based here documents and: implementation, and example 3 similar

If there are inverted quotes in the annotated content, the error will be

Copy Code code as follows:
: <<block
.... Multiple lines of content being commented
Block

Troubleshoot problems with inverted quotes in comments

Copy Code code as follows:
:<< ' Block
.... Multiple lines of content being commented
Block '

Or simply leave a single quote
Copy Code code as follows:
:<< '
.... Multiple lines of content being commented
'

The second: when there are parentheses in the content of the Times syntax error, but there are inverted quotes, quotes without problems

Copy Code code as follows:
:|| {
.... Multiple lines of content being commented
}

Third: Error in syntax errors such as parenthesis quotes in annotation content

Copy Code code as follows:
If false; Then
.... Multiple lines of content being commented
Fi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.