Problem duplicated on AMD64/SuSE9.1 GNU Linux and Apple G5/MacOS 10.3.6.
Both ship wit the same version of bash as given above.
"man bash" says in the Parameter Expansion section under Substring Expansion
(${parameter:offset:length}) that "[i]f offset evaluates to a number less
than zero, the value is used as an offset from the end of the value of
parameter."
However, experience suggests otherwise:
$ xyz='abcdefghijkl'
$ echo ${xyz}
abcdefghijkl
$ echo ${xyz:3} # Positive offset - OK
defghijkl
$ echo ${xyz:-3} # Negative offset - Not OK
abcdefghijkl
I don't know whether this is a bug in the manual page or the bash program.
Or in my understanding of the manual page.
Take a look at the other parameter expansions (and what :- means).
$ xyz=
$ echo ${xyz:-3}
3
$ echo ${xyz:-3:1}
3:1
$ xyz=abcdefghijkl
$ echo ${xyz: -3}
jkl
$ echo ${xyz: -3:1}
j
--
Chris F.A. Johnson http://cfaj.freeshell.org
=================================================================
Everything in moderation -- including moderation