Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Strange Error in let command
- X-seq: zsh-users 10236
- From: "Com MN PG P E B Consultant 3" <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>
- To: "zsh-users Mailinglist" <zsh-users@xxxxxxxxxx>
- Subject: Strange Error in let command
- Date: Wed, 10 May 2006 12:58:19 +0200
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Thread-index: AcZ0IKWSYeyHWp3NTJ+LsPu4thJxkg==
- Thread-topic: Strange Error in let command
I have a variable which is guaranteed to either contain a number
(expressing a duration in seconds),
or a number followed by the letter 'm' (expressing a duration in
minutes). My zsh scripts converts
this number so that it always contains the duration in seconds.
Here is one possibility how to do it:
delay=20m # For example, duration is 20 minutes
...
delay=$((${delay/%m/*60}))
# Now delay contains 1200
The trick is to replace a trailing 'm' by '*60' and apply arithmetic
evaluation
on it. No big deal so far.
But then I thought that this could be also written by a let statement:
((delay=${delay/%m/*60}))
Strangely, this rises the error message
bad math expression: operator expected at `m'
It is interesting that the very similar statement,
((delay1=${delay/%m/*60})) # Stores duration to delay1
DOES work. It is as if in the former case, the occurrence of the word
'delay'
to the left of the equal sign did undergo substitution as well. Is this
a zsh
bug, or did I make a mistake here?
Ronald
--
Ronald Fischer (phone +49-89-63676431)
mailto:mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author