Bash 4.2 added support for negative substring lengths:
http://tldp.org/LDP/abs/html/abs-guide.html#SUBSTREXTR01
Example 37-12. Negative parameter in string-extraction construct
When the "length" parameter is negative, it serves as an offset-from-end parameter.
For example, the following outputs "World" when tested on Ubuntu:
STR="Hello World!"
echo ${STR:6:-1}
But in OS X (GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin14.5.0)), that usage produces the following error:
-1: substring expression < 0
Is this OS X specific, or was it disabled again in later bash updates? Is there a way to enable this functionality for OS X?