From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: ${var: -1:1} vs. ${var:-1:1}
Date: Sat, 17 Nov 2012 14:56:29 -0800 [thread overview]
Message-ID: <50A8161D.1030302@eastlink.ca> (raw)
In-Reply-To: <CANPayMQK+nYt2aUCrYF1ePUq0HDmByT3kAS7UXtE-ZutxyLJnw@mail.gmail.com>
On 17/11/12 01:48 PM, Moritz Bunkus wrote:
> Hey,
>
> if you don't put a space there then the parser thinks that this the
> "${variable:-default} syntax which means "expands to the variable's
> content if the variable is set and to 'default' if it is unset". Can
> be seen easily with:
>
> [0 mosu@sweet-chili ~] echo ${thisvarisnotset:-1:1}
> 1:1
>
> So the '1:1' is interpreted as the 'default'. You probably never saw
> that result because you were trying to extract the last character from
> a string, meaning you always used a variable that was set.
>
> Kind regards,
> mosu
>
I see. But it's still lousy syntax IMHO.
next prev parent reply other threads:[~2012-11-17 23:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-17 21:10 Ray Andrews
2012-11-17 21:48 ` Moritz Bunkus
2012-11-17 22:56 ` Ray Andrews [this message]
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=50A8161D.1030302@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).