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

'$1' indexing.



Hi!

First post. I thought I'd try zsh given how well spoken about it is. My first exercise has been to try to convert my bash functions to zsh, and it has not gone smoothly, but most problems have proved to be solvable. But what do you guys think of this:

function z
{
var=$1
echo "var:/${1:0:1}/${1:1:1}/${1:2:1}/"
echo "var:/${var:0:1}/${var:1:1}/${var:2:1}/"

}

$ z abcde

var: /a/a/b/
var: /a/b/c/

Surely the indexing of '$1' is wrong? I can assign the value to 'var' and all is well but I don't think I should have to.

Thoughts?



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