Denys Vlasenko | 5dad7bd | 2017-07-06 19:48:20 +0200 | [diff] [blame] | 1 | parameter=abcdef |
| 2 | offset=2 |
| 3 | noffset=-2 |
| 4 | echo "parameter '${parameter}'" |
| 5 | echo "varoffset2 '${parameter:${offset}}'" |
| 6 | echo "varoffset-2 '${parameter:${noffset}}'" |
| 7 | echo "literal '2' '${parameter:2}'" |
Denys Vlasenko | 74d20e6 | 2017-07-06 19:50:42 +0200 | [diff] [blame^] | 8 | # This is not interpreted as ${VAR:POS{:LEN}}, |
Denys Vlasenko | 5dad7bd | 2017-07-06 19:48:20 +0200 | [diff] [blame] | 9 | # but as ${VAR:=WORD} - if VAR is unset or null, substitute WORD |
| 10 | echo "literal '-2' '${parameter:-2}'" |
| 11 | echo "literal ' -2' '${parameter: -2}'" |