From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: ${var: -1:1} vs. ${var:-1:1}
Date: Sat, 17 Nov 2012 13:10:20 -0800 [thread overview]
Message-ID: <50A7FD3C.9070306@eastlink.ca> (raw)
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.
next reply other threads:[~2012-11-17 21:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-17 21:10 Ray Andrews [this message]
2012-11-17 21:48 ` Moritz Bunkus
2012-11-17 22:56 ` Ray Andrews
2012-11-18 1:31 ` Bart Schaefer
2012-11-18 2:25 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50A7FD3C.9070306@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).