bug-bash
[Top][All Lists]
Advanced

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

documentation for ${@: -1} is unclear


From: Emanuele Torre
Subject: documentation for ${@: -1} is unclear
Date: Tue, 20 Dec 2022 21:40:29 +0100

The bash manual says:

 If parameter is ‘@’ or ‘*’, the result is length positional parameters
 beginning at offset. A negative offset is taken relative to one greater
 than the greatest positional parameter, so an offset of -1 evaluates to
 the last positional parameter. It is an expansion error if length
 evaluates to a number less than zero.

But -1 will evaluate to 0 if there are no positional arguments.

So that should probably say "so an offset of -1 evaluates to the last
positional parameter (or 0 if there no positional arguments)", or
something along the lines of "so an offset of -1 evlauates to $#" to
avoid confusion.

 emanuele6



reply via email to

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