* Strange Error in let command
@ 2006-05-10 10:58 Com MN PG P E B Consultant 3
2006-05-10 16:56 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Com MN PG P E B Consultant 3 @ 2006-05-10 10:58 UTC (permalink / raw)
To: zsh-users Mailinglist
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@siemens.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Strange Error in let command
2006-05-10 10:58 Strange Error in let command Com MN PG P E B Consultant 3
@ 2006-05-10 16:56 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2006-05-10 16:56 UTC (permalink / raw)
To: zsh-users Mailinglist
On May 10, 12:58pm, Com MN PG P E B Consultant 3 wrote:
}
} delay=20m # For example, duration is 20 minutes
} ((delay=${delay/%m/*60}))
}
} Strangely, this rises the error message
}
} bad math expression: operator expected at `m'
This works fine for me, in 4.2.0 and 4.2.6 and 4.3.2-dev-1, so I suspect
there's something that seems unrelated but is causing you side-effects.
What version of zsh are you using? Have you tried this with "zsh -f"?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-10 16:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-10 10:58 Strange Error in let command Com MN PG P E B Consultant 3
2006-05-10 16:56 ` Bart Schaefer
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).