On Mon, Apr 24, 2017 at 08:44:11AM -0400, Greg Wooledge wrote: > On Mon, Apr 24, 2017 at 12:59:01PM +0200, wer...@suse.de wrote: > > V_NAME=Friday > > for (( INDEX=0; INDEX<$((10-$(expr length $V_NAME))); INDEX++ )) > > The outer (( )) in the C-style for loop already create an arithmetic > expression context. You don't need to use $(( )) inside them. You can > simply write: > > for (( INDEX=0; INDEX<10-${#V_NAME};; INDEX++ )) > > By the way, the [ ] index syntax in an indexed (not associative) array > expansion works the same way. You can simply write: > > "${a[x+1]}" > > instead of > > "${a[$((x+1))]}"
Yes I know ... nevertheless, the initial code should not trigger an error ... to make it sure, the initial example was given by a user asking me why this triggers an error, which IMHO it should not. -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr
signature.asc
Description: PGP signature