Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
${var:1:1:=y}
- X-seq: zsh-users 19801
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: ${var:1:1:=y}
- Date: Tue, 03 Feb 2015 15:12:08 -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
We can of course do this:
variable=${var:=xy}
I'm wanting the naive expansion of that syntax to do this:
variable=${var:1:1:=y}
... but it doesn't work. Can something like that be done?
At the moment I'm doing this:
variable=${var:1:1}
[ -n "$variable" ] || variable=y
... which is perfectly fine, but the above pseudosyntax would be elegant
if it could be made workable.
And I found something that puzzles me:
test ()
{
echo $1
echo ${1:0:1}
/bin/echo ${1:0:1}
echo ${1:1:1}
echo ${1:0:1}${1:1:1}
echo ${1:1:1}${1:0:1}
}
$ test -a
-a
[nothing]
-
a
-a
a-
... If I entered a valid switchofcourse I'd expect that to be eaten
but a solitary dash? Bug? /bin/echo behaves as I'd expect.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author