Use colons in shell with equal signs, plus signs, and minus signs

Source: Internet
Author: User

Use colons in shell with equal signs, plus signs, and minus signs
In question 13, there were cases of colons and equal signs mentioned, with colons, as long as they are null (undefined, null) can be overwritten;
If no colon exists, it can be overwritten only when it is undefined. However, the return value is not described in detail.
1. colon and equal sign



2. colon and minus sign



3. colon and plus sign



4. running result [SQL] ############# Test ############## Case 1: varible unset str = abcd var = abcd Case 2: varible null str = var = str = abcd var = abcd Case 3: varible not null str = xyz var = xyz ############## Test -########## ### Case 1: varible unset str = var = abcd Case 2: varible null str = var = abcd Case 3: varible not null str = xyz var = xyz ############### Test + ########## ### Case 1: varible unset str = var = Case 2: varible null str = var = abcd str = var = Case 3: varible not null str = xyz var = abcd 5. summary
1. Set the default value (: =): When 1.1 is undefined, the default value is generated;
1.2 If a null value is entered, the default value is generated with a colon;
If 1.3 has a value, it is not overwritten.
2. Default Value (:-): When 2.1 is undefined, the original variable str will not change; the returned value var can be overwritten;
2.2 If the value is null, the variable str does not change;
If 2.3 has a value, it is not overwritten.
3. overwrite the default value (: +): When 3.1 is undefined, the original variable str and return value var will not change;
3.2 If the value is null, the original variable str will not change;
If 3.3 has a value, override the default value of the str variable.
Note:
1. =,-if there is a value, the original variable remains unchanged. Only: + can be overwritten;
2. +,-if there is no value, the original variable str is still blank.

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.