[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Negative offsets in variable substitution

From: Bob Dowling
Subject: Negative offsets in variable substitution
Date: Tue, 25 Jan 2005 20:18:29 +0000

Version of bash:        2.05b.0(1)-release

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}
$ echo ${xyz:3}         # Positive offset - OK
$ echo ${xyz:-3}        # Negative offset - Not OK

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]