> > echo ".ds head-str ${str: -1}"
> The compatible syntax is ${str:-1}.
I wonder if that is meant, though.
Bash also has
${parameter:offset}
${parameter:offset:length}
Substring Expansion. Expands to up to length characters of
the value of parameter starting at the character specified
by offset.
with the caveat that
Note that a negative offset must be separated from the
colon by at least one space to avoid being confused with
the :- expansion.
This latter is something that all Bourne-compatible shells
understand, here in a summary by POSIX:
| parameter set | parameter set | parameter unset
| and not null | but null |
-------------------+----------------------+-----------------+----------------
${parameter:-word} | substitute parameter | substitute word | substitute word
${parameter-word} | substitute parameter | substitute null | substitute word
${parameter:=word} | substitute parameter | assign word | assign word
${parameter=word} | substitute parameter | substitute null | assign word
${parameter:?word} | substitute parameter | error, exit | error, exit
${parameter?word} | substitute parameter | substitute null | error, exit
${parameter:+word} | substitute word | substitute null | substitute null
${parameter+word} | substitute word | substitute word | substitute null
but the purpose of this differs from that of the bashism above.