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.