Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
${var: -1:1} vs. ${var:-1:1}
- X-seq: zsh-users 17403
 
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
 
- To: zsh-users@xxxxxxx
 
- Subject: ${var: -1:1} vs. ${var:-1:1}
 
- Date: Sat, 17 Nov 2012 13:10:20 -0800
 
- List-help: <mailto:zsh-users-help@zsh.org>
 
- List-id: Zsh Users List <zsh-users.zsh.org>
 
- List-post: <mailto:zsh-users@zsh.org>
 
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
 
I just wasted an hour trying to extract the last character from a 
string. My problem was that I did: "${var:-1:1}" and didn't put a space 
in front of the minus sign.  Bash has the same problem, so this isn't a 
zsh specific issue, but I'd feel a lot better if someone could explain 
why that space is necessary. All the shells seem to have these little 
gotchas with spaces. Sometimes they're ignored, sometimes mandatory and 
sometimes forbidden. It sure is a PITA.  I can only compare this to C, 
where such problems are nonexistent. If there is some sort of master 
plan governing spacing, I'd sure like to know what it is.
Thanks, sorry to bitch.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author