Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: did the way arrays get indexed change between 4.2 and 4.3?

On Jul 24,  4:14pm, William Scott wrote:
}          rlength="20"
}          echo -ne "\e]1;$tab_label[-$rlength,-1]\a"
} On 4.3.4 this works great.  On 4.2.3, if the original string has  
} fewer than 20 characters, the tab is blank.

The flavor of this that works is very recent.  What you're seeing in
4.2.3 is what you'll find pretty much universally in "stable" versions
of the shell shipped with various OSs and Linux versions.

I'm not sure which of PWS's array changes led to this handling of out-
of-bounds indices on strings, and I'm not sure it was intentional
although it makes some sense.  Previously all invalid positions were
considered to be off the right end of the array, and a range from
right to left produces an empty result.
} Is there a decent work-around, as I hate to conditionally test for  
} the zsh version every time the tab dynamically updates.

There's a much simpler formulation that works the same (AFAIK) in all
versions that have the (l) (that's a lowercase L) parameter flag:

	echo -ne "\e]1;${(l:rlength:)tab_label}\a"

Messages sorted by: Reverse Date, Date, Thread, Author